DataDescriptorServiceImpl extends BaseGenericServiceImpl<DataDescriptor> implements DataDescriptorService { @Override public List<DataDescriptor> findByNames(final Collection<String> names) { return getGenericDao().findByNamedQuery("DATADESCRIPTOR.IN.NAMES", names); } DataDescriptorServiceImpl(final GenericDAO<DataDescriptor, Long> genericDao); @Override List<DataDescriptor> findByNames(final Collection<String> names); @Override DataDescriptor findByName(final String name);  }
@Test public void testFindByNames() throws Exception { assertTrue(dataDescriptorService.findByNames(Arrays.asList("D001", "D002")).isEmpty()); final DataDescriptor desc001 = dataDescriptorService.getGenericDao().getEntityFactory().getByIface(DataDescriptor.class); desc001.setName("D001"); desc001.setType(DataDescriptor.TYPE_WEBINF_XML); desc001.setValue("attributenames.xml"); dataDescriptorService.create(desc001); final DataDescriptor desc002 = dataDescriptorService.getGenericDao().getEntityFactory().getByIface(DataDescriptor.class); desc002.setName("D002"); desc002.setType(DataDescriptor.TYPE_WEBINF_XML); desc002.setValue("attributenames.xml"); dataDescriptorService.create(desc002); final DataDescriptor desc003 = dataDescriptorService.getGenericDao().getEntityFactory().getByIface(DataDescriptor.class); desc003.setName("D003"); desc003.setType(DataDescriptor.TYPE_WEBINF_XML); desc003.setValue("attributenames.xml"); dataDescriptorService.create(desc003); final List<DataDescriptor> search = dataDescriptorService.findByNames(Arrays.asList("D001", "D002")); assertFalse(search.isEmpty()); assertEquals(2, search.size()); for (final DataDescriptor dd : search) { assertTrue("D001".equals(dd.getName()) || "D002".equals(dd.getName())); } }