ProductDao extends HibernateDao<Product, Long> { public Product getProductByUuid(final String uuid) { return getHibernateTemplate().execute(session -> { Query query = session.createQuery("FROM Product WHERE uuid=?"); query.setParameter(0, uuid, StandardBasicTypes.STRING); List list = query.list(); return (Product) (list.isEmpty() ? null : list.get(0)); }); }  Iterator<Product> scrollFiltered(String filter, final Long collection_id, int skip); @Override void deleteAll(); @Override void delete(Product product); void setIndexes(Product product, List<MetadataIndex>indexes); void setIndexes(Long id, List<MetadataIndex>indexes); Product getProductByUuid(final String uuid); Iterator<Product> getAllProducts(); Product getProductByIdentifier(final String identifier); @Override synchronized Product create(Product p); @Override List<Product> listCriteria(DetachedCriteria detached, int skip, int top); @Override List<Product> executeHQLQuery(final String hql,
         final List<SQLVisitor.SQLVisitorParameter> parameters, final int skip, final int top); @SuppressWarnings("unchecked") List<LoggableProduct> getProductUUIDs(String hql, List<SQLVisitorParameter> hqlParameters, int skip, int top);  }
@Test public void getProductByUuid () { String valid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa6"; String invalid = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb6"; User user = new User (); user.setUUID ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0"); user.setUsername ("koko"); Product product = dao.getProductByUuid(valid); Assert.assertNotNull (product); Assert.assertEquals (product.getId ().intValue (), 6); product = dao.getProductByUuid(invalid); Assert.assertNull (product); product = dao.getProductByUuid(valid); Assert.assertNotNull (product); Assert.assertEquals (product.getId ().intValue (), 6); product = dao.getProductByUuid(null); Assert.assertNull (product); }