From: Rob M. (JIRA) <no...@at...> - 2005-09-14 23:04:55
|
SubqueryExpression throws ClassCastException on DetachedCriteria subqueries --------------------------------------------------------------------------- Key: HHH-957 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-957 Project: Hibernate3 Type: Bug Versions: 3.0.5 Environment: Oracle 9i, but probably not DB specific. Reporter: Rob MacGrogan Priority: Minor Attachments: SubqueryExpression.java The toSqlString() method in SubqueryExpression contains a line that casts a Criteria object to CriteriaImpl in order to call the getSession() method. However, if DetachedCriteria is used as a subquery in a Criteria query, the underlying Criteria object will be CriteriaImpl.Subcriteria, thus a ClassCastException will be thrown. I have created a bug fix. Add the following method to SubqueryExpression: private SessionImpl getSessionImpl(Criteria criteria) { SessionImpl session = null; if (criteria instanceof CriteriaImpl) { CriteriaImpl impl = (CriteriaImpl)criteria; session = impl.getSession(); } else if (criteria instanceof CriteriaImpl.Subcriteria){ CriteriaImpl.Subcriteria sub = (CriteriaImpl.Subcriteria)criteria; //Alert! Recursive call here! session = getSessionImpl(sub.getParent()); } return session; } And then replace the offending line in toSqlString() with a call to the new method. Attached is SubqueryExpression with proposed changes in place. -- 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 |
From: Rodrigo S. de C. (JIRA) <no...@at...> - 2005-11-05 05:18:14
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-957?page=all ] Rodrigo S. de Castro updated HHH-957: ------------------------------------- Attachment: SubqueryExpression.java Minor changes (classes names update) to make it compile with Hibernate 3.1rc2. > SubqueryExpression throws ClassCastException on DetachedCriteria subqueries > --------------------------------------------------------------------------- > > Key: HHH-957 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-957 > Project: Hibernate3 > Type: Bug > Versions: 3.0.5 > Environment: Oracle 9i, but probably not DB specific. > Reporter: Rob MacGrogan > Priority: Minor > Attachments: SubqueryExpression.java, SubqueryExpression.java > > > The toSqlString() method in SubqueryExpression contains a line that casts a Criteria object to CriteriaImpl in order to call the getSession() method. However, if DetachedCriteria is used as a subquery in a Criteria query, the underlying Criteria object will be CriteriaImpl.Subcriteria, thus a ClassCastException will be thrown. > I have created a bug fix. Add the following method to SubqueryExpression: > private SessionImpl getSessionImpl(Criteria criteria) { > SessionImpl session = null; > if (criteria instanceof CriteriaImpl) { > CriteriaImpl impl = (CriteriaImpl)criteria; > session = impl.getSession(); > } > else if (criteria instanceof CriteriaImpl.Subcriteria){ > CriteriaImpl.Subcriteria sub = (CriteriaImpl.Subcriteria)criteria; > //Alert! Recursive call here! > session = getSessionImpl(sub.getParent()); > } > return session; > } > And then replace the offending line in toSqlString() with a call to the new method. > Attached is SubqueryExpression with proposed changes in place. -- 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 |
From: Rodrigo S. de C. (JIRA) <no...@at...> - 2005-11-05 05:20:18
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-957?page=comments#action_20626 ] Rodrigo S. de Castro commented on HHH-957: ------------------------------------------ The same problem here. After applying this patch, DetachedCriteria as subquery worked for my Criteria. I had to make some minor changes in order to make it compile (names update) under Hibernate 3.1rc2 and the file is attached to this issue. Thanks for the patch, I hope it gets applied soon. > SubqueryExpression throws ClassCastException on DetachedCriteria subqueries > --------------------------------------------------------------------------- > > Key: HHH-957 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-957 > Project: Hibernate3 > Type: Bug > Versions: 3.0.5 > Environment: Oracle 9i, but probably not DB specific. > Reporter: Rob MacGrogan > Priority: Minor > Attachments: SubqueryExpression.java, SubqueryExpression.java > > > The toSqlString() method in SubqueryExpression contains a line that casts a Criteria object to CriteriaImpl in order to call the getSession() method. However, if DetachedCriteria is used as a subquery in a Criteria query, the underlying Criteria object will be CriteriaImpl.Subcriteria, thus a ClassCastException will be thrown. > I have created a bug fix. Add the following method to SubqueryExpression: > private SessionImpl getSessionImpl(Criteria criteria) { > SessionImpl session = null; > if (criteria instanceof CriteriaImpl) { > CriteriaImpl impl = (CriteriaImpl)criteria; > session = impl.getSession(); > } > else if (criteria instanceof CriteriaImpl.Subcriteria){ > CriteriaImpl.Subcriteria sub = (CriteriaImpl.Subcriteria)criteria; > //Alert! Recursive call here! > session = getSessionImpl(sub.getParent()); > } > return session; > } > And then replace the offending line in toSqlString() with a call to the new method. > Attached is SubqueryExpression with proposed changes in place. -- 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 |
From: bible b. (JIRA) <no...@at...> - 2006-05-18 12:09:18
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-957?page=comments#action_23125 ] bible be commented on HHH-957: ------------------------------- I was having the same issue with hibernate 3.1.3. The proposed fix works perfectly, and I'm building some pretty complex queries. Please include this in the release asap! Thanks! > SubqueryExpression throws ClassCastException on DetachedCriteria subqueries > --------------------------------------------------------------------------- > > Key: HHH-957 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-957 > Project: Hibernate3 > Type: Bug > Versions: 3.0.5 > Environment: Oracle 9i, but probably not DB specific. > Reporter: Rob MacGrogan > Priority: Minor > Attachments: SubqueryExpression.java, SubqueryExpression.java > > > The toSqlString() method in SubqueryExpression contains a line that casts a Criteria object to CriteriaImpl in order to call the getSession() method. However, if DetachedCriteria is used as a subquery in a Criteria query, the underlying Criteria object will be CriteriaImpl.Subcriteria, thus a ClassCastException will be thrown. > I have created a bug fix. Add the following method to SubqueryExpression: > private SessionImpl getSessionImpl(Criteria criteria) { > SessionImpl session = null; > if (criteria instanceof CriteriaImpl) { > CriteriaImpl impl = (CriteriaImpl)criteria; > session = impl.getSession(); > } > else if (criteria instanceof CriteriaImpl.Subcriteria){ > CriteriaImpl.Subcriteria sub = (CriteriaImpl.Subcriteria)criteria; > //Alert! Recursive call here! > session = getSessionImpl(sub.getParent()); > } > return session; > } > And then replace the offending line in toSqlString() with a call to the new method. > Attached is SubqueryExpression with proposed changes in place. -- 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 |
From: Mikle F. (JIRA) <no...@at...> - 2006-06-27 08:48:00
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-957?page=comments#action_23426 ] Mikle Freeland commented on HHH-957: ------------------------------------ Still not fixed in hibernate 3.2.0 cr2 > SubqueryExpression throws ClassCastException on DetachedCriteria subqueries > --------------------------------------------------------------------------- > > Key: HHH-957 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-957 > Project: Hibernate3 > Type: Bug > Versions: 3.0.5 > Environment: Oracle 9i, but probably not DB specific. > Reporter: Rob MacGrogan > Priority: Minor > Attachments: SubqueryExpression.java, SubqueryExpression.java > > > The toSqlString() method in SubqueryExpression contains a line that casts a Criteria object to CriteriaImpl in order to call the getSession() method. However, if DetachedCriteria is used as a subquery in a Criteria query, the underlying Criteria object will be CriteriaImpl.Subcriteria, thus a ClassCastException will be thrown. > I have created a bug fix. Add the following method to SubqueryExpression: > private SessionImpl getSessionImpl(Criteria criteria) { > SessionImpl session = null; > if (criteria instanceof CriteriaImpl) { > CriteriaImpl impl = (CriteriaImpl)criteria; > session = impl.getSession(); > } > else if (criteria instanceof CriteriaImpl.Subcriteria){ > CriteriaImpl.Subcriteria sub = (CriteriaImpl.Subcriteria)criteria; > //Alert! Recursive call here! > session = getSessionImpl(sub.getParent()); > } > return session; > } > And then replace the offending line in toSqlString() with a call to the new method. > Attached is SubqueryExpression with proposed changes in place. -- 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 |