nest « Criteria « JPA Q&A





1. Java / Hibernate: Problem with nested object criterias    stackoverflow.com

I'm having problems with a Hibernate criteria. I'm trying to make a Criteria where I look at the id of a member object of the class the query returns. For example:
Criteria crit ...

3. How to access nested object, using Criteria    forum.hibernate.org

Hi, I am new to Hibernate and trying to access nested object. Like I have 3 classes: public class A{ B bObj; getBObj() } public class B{ C cObj; getCObj(); } public class C{ getDate(); } My Hibernate code is: Criteria criteria = session.createCriteria(A.class) .createAlias("B", "b") .createAlias("b.cObj", "c") .addOrder(org.hibernate.criterion.Order.asc("c.Date")); List list = criteria.list(); I am getting empty list. I would be ...

4. Deeply nested Criteria Restriction    forum.hibernate.org

I am trying to do the Criteria equivalent of the following query. Code: from MatchSet m where m.memberships.subscription.client.id=:clientId I have tried the following, but it doesn't handle the implicit joins, though it does detect the correct field name for client.id at the end of the path: Code: Criteria matchSetCriteria = session.createCriteria(MatchSet.class); matchSetCriteria.createAlias("memberships.subscription.client", "client") .add(Restrictions.eq("client.id", clientId)); The stack trace and ...

5. nested or statements in hibernate criteria    forum.hibernate.org

Anyone has come across the problem where you need to define multiple or statement in a hibernate criteria. Consider the following code segment: Code: Criteria crit = session.createCriteria(Project.class); Criteria jobs = crit.createCriteria("jobTypes"); jobs.add(Restrictions.or(Restrictions.eq("id", 1), ...