Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: James Rivera   on Mar 22 In Java Category.

  
Question Answered By: Perdita Lopez   on Mar 22

Hibernate criteria  API could handle this situation without the need to write HQL. Consider that A has a collection of B and you what to put criteria on b attributes then here is what we can do with criteria API:



Criteria criteria = getSession().createCriteria(A.class).setFetchMode("b", FetchMode.JOIN);

criteria.add(Restrictions.eq("b.attribute1",somthing);



I‘ve used it many time and it worked. You can deal with more complicated queries with this technique but be careful of performance in some situations.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Hibernate Criteria question Or get search suggestion and latest updates.


Tagged: