@Test public void searchProductListByName_shouldFindListWithExistingProductByName() { List<Product> products = persistence.searchProductList(existingProduct.getName()); assertThat(products.size(), is(1)); assertThat(existingProduct.compareTo(products.get(0)), is(0)); }
@Override public List<Product> searchProductList(final String name) { Query query = getEntityManager().createQuery("select p from Product p where p.name like :name"); query.setParameter("name", "%" + name + "%"); @SuppressWarnings("unchecked") List<Product> products = (List<Product>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] products by name[{}]", products.size(), name); return products; }
ProductBasePersistence extends AbstractBasePersistence<Product, String> implements ProductMapper { @Override public List<Product> searchProductList(final String name) { Query query = getEntityManager().createQuery("select p from Product p where p.name like :name"); query.setParameter("name", "%" + name + "%"); @SuppressWarnings("unchecked") List<Product> products = (List<Product>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] products by name[{}]", products.size(), name); return products; } }
ProductBasePersistence extends AbstractBasePersistence<Product, String> implements ProductMapper { @Override public List<Product> searchProductList(final String name) { Query query = getEntityManager().createQuery("select p from Product p where p.name like :name"); query.setParameter("name", "%" + name + "%"); @SuppressWarnings("unchecked") List<Product> products = (List<Product>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] products by name[{}]", products.size(), name); return products; }  }
ProductBasePersistence extends AbstractBasePersistence<Product, String> implements ProductMapper { @Override public List<Product> searchProductList(final String name) { Query query = getEntityManager().createQuery("select p from Product p where p.name like :name"); query.setParameter("name", "%" + name + "%"); @SuppressWarnings("unchecked") List<Product> products = (List<Product>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] products by name[{}]", products.size(), name); return products; }  @Override List<Product> getProductListByCategory(final String categoryId); @Override Product getProduct(final String productId); @Override List<Product> searchProductList(final String name); }
ProductBasePersistence extends AbstractBasePersistence<Product, String> implements ProductMapper { @Override public List<Product> searchProductList(final String name) { Query query = getEntityManager().createQuery("select p from Product p where p.name like :name"); query.setParameter("name", "%" + name + "%"); @SuppressWarnings("unchecked") List<Product> products = (List<Product>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] products by name[{}]", products.size(), name); return products; }  @Override List<Product> getProductListByCategory(final String categoryId); @Override Product getProduct(final String productId); @Override List<Product> searchProductList(final String name);  }