Guest User

Untitled

a guest
Oct 16th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. CriteriaBuilder builder = sessionFactory.getCurrentSession().getCriteriaBuilder();
  2. CriteriaQuery<String> criteria = builder.createQuery(String.class);
  3. Root<EstimatedObject> root = criteria.from(EstimatedObject.class);
  4.  
  5. criteria.select(root.get("customer")).distinct(true);
  6.  
  7. Predicate predicate = builder.like(
  8. builder.lower(root.get("customer")),
  9. builder.lower(builder.literal("%" + like + "%"))
  10. );
  11. criteria.where(predicate);
  12.  
  13. List<String> customerList = sessionFactory.getCurrentSession().createQuery(criteria).getResultList();
  14.  
  15. customerList.forEach(System.out::println);
  16.  
  17. Hibernate: select distinct estimatedo0_.customer as col_0_0_
  18. from directories_object.estimated_object estimatedo0_
  19. where lower(estimatedo0_.customer) like lower(?)
Add Comment
Please, Sign In to add comment