-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem in "detaching" a criteria
PostPosted: Wed Nov 29, 2006 8:07 pm 
Newbie

Joined: Thu Oct 05, 2006 9:12 am
Posts: 1
Location: Switzerland
Hibernate version: 3.2

For the moment I'm using a Criteria that is working well:

Code:
Session hibernateSession = HibernateUtil.getSessionFactory().getCurrentSession();
Criteria crit = hibernateSession.createCriteria("org.SVM.Hibernate.model.ProductionViewDescription");
crit.createCriteria("creatorDescriptions").add(Restrictions.ilike("familyName","Doe"));
       
List result = crit.list();


Now I want to detach the criteria about the creatorDescriptions, so I tried stuff like this:

Code:
Session hibernateSession = HibernateUtil.getSessionFactory().getCurrentSession();
Criteria crit = hibernateSession.createCriteria("org.SVM.Hibernate.model.ProductionViewDescription");

DetachedCriteria creatorCrit = DetachedCriteria.forClass(CreatorDescription.class);
creatorCrit.add(Restrictions.ilike("familyName","Doe"));
       
crit.add(Subqueries.propertyIn("creatorDescriptions",creatorCrit));
//or
crit.add(Subqueries.exists(creatorCrit));
       
List result = crit.list();


The subquery alone is working:
Code:
List result = creatorCrit.getExecutableCriteria(hibernateSession).list();


But in both case when putting it in the crit I get following error:
Code:
java.lang.NullPointerException
        at org.hibernate.loader.criteria.CriteriaQueryTranslator.getProjectedTypes(CriteriaQueryTranslator.java:317)
        at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:56)
        at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:333)
        at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
        at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1514)
        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)


Can someone help me?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.