[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-158) nested DetachedCriteria throwing NullPointerException
Dan Adams (JIRA)
noreply at atlassian.com
Mon Aug 14 17:37:23 EDT 2006
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-158?page=comments#action_23933 ]
Dan Adams commented on HHH-158:
-------------------------------
I definitely would like to see a fix for this.
> nested DetachedCriteria throwing NullPointerException
> -----------------------------------------------------
>
> Key: HHH-158
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-158
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.0 beta 4
> Reporter: Jérôme Boehm
> Assignee: Gavin King
> Attachments: testcase.zip
>
>
> It seems that it is not possible to nest DetachedCriteria.
> This is examplified in the testWithReturnedObject() method of the attached TestCase.
> When nesting DetachedCriteria using DetachedCriteria.add(Subqueries.<a_Subqueries_static_method>) twice, we get the following exception:
> java.lang.NullPointerException
> at org.hibernate.criterion.SubqueryExpression.getTypedValues(SubqueryExpression.java:73)
> at org.hibernate.loader.criteria.CriteriaQueryTranslator.getQueryParameters(CriteriaQueryTranslator.java:230)
> at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:50)
> at org.hibernate.criterion.Junction.toSqlString(Junction.java:58)
> at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:312)
> at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1208)
> at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)
> at test.subqueries.SubqueriesTest.main(SubqueriesTest.java:41)
> Then, after "correcting" SubqueryExpression so that the params instance variable is initialized (see the attached Corrected_SubqueryExpression), it seems that the nested aliases are not properly propagated, which is examplified in testWithNoReturnedObject().
> The generated sql is:
> select this_.a_id as a1_0_ from a this_ where exists (select this0__.b_id as y0_ from b this0__ where this0__.a_id=this_.a_id and exists (select this0__.c_id as y0_ from c this0__ where this0__.b_id=this0__.b_id))
> I think it should be (notice the this1__ alias for table c):
> select this_.a_id as a1_0_ from a this_ where exists (select this0__.b_id as y0_ from b this0__ where this0__.a_id=this_.a_id and exists (select this1__.c_id as y0_ from c this1__ where this1__.b_id=this0__.b_id))
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list