[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-158?page=co...
]
Rüdiger Hain commented on HHH-158:
----------------------------------
So is there any chance to have this patch integrated into one of the next releases ?
Christian - not every Hibernate user concerned about this bug is able to provide a patch,
let alone a robust fix. So 25 votes simply means there is an urgent need for this to be
fixed, you cant seriously expect those voters are all Hibernate experts digging into the
code to get it done.
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