ExporterMetadataCurator extends AbstractHibernateCurator<ExporterMetadata> { public ExporterMetadata getByType(String type) { return (ExporterMetadata) this.currentSession().createCriteria(ExporterMetadata.class) .add(Restrictions.eq("type", type)) .uniqueResult(); } @Inject  ExporterMetadataCurator(); ExporterMetadata getByType(String type); ExporterMetadata getByTypeAndOwner(String type, Owner owner);  }
@Test public void getByType() { ExporterMetadata em = new ExporterMetadata(); em.setType(ExporterMetadata.TYPE_SYSTEM); em.setExported(new Date()); assertNull(em.getId()); ExporterMetadata emdb = emc.create(em); assertNull(emc.getByType(ExporterMetadata.TYPE_PER_USER)); assertEquals(emdb, emc.getByType(ExporterMetadata.TYPE_SYSTEM)); }