[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-158?page=co...
]
Ido Tzang commented on HHH-158:
-------------------------------
is there a designated version for a fix for this issue ?
it's a huge limitation in my opinion (limits us in using Criteria API for complex
queries)
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira