[Hibernate-JIRA] Resolved: (HHH-957) SubqueryExpression throws ClassCastException on DetachedCriteria subqueries
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-957?page=co... ]
Gail Badner resolved HHH-957.
-----------------------------
Assignee: Gail Badner
Resolution: Fixed
Fix Version/s: 3.2.6
This appears to have been fixed in 3.2.6 by HHH-952.
> SubqueryExpression throws ClassCastException on DetachedCriteria subqueries
> ---------------------------------------------------------------------------
>
> Key: HHH-957
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-957
> Project: Hibernate3
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.0.5
> Environment: Oracle 9i, but probably not DB specific.
> Reporter: Rob MacGrogan
> Assignee: Gail Badner
> Priority: Minor
> Fix For: 3.2.6
>
> Attachments: subcriteria-patch.txt, SubqueryExpression.java, 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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 8 months
[Hibernate-JIRA] Commented: (HHH-1657) hql update generate wrong sql with joined subclass hierarcy
by Peter Lupo (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657?page=c... ]
Peter Lupo commented on HHH-1657:
---------------------------------
It certainly worths a try.
Even though the ORDER BY problem seems to be another problem, it seems to manifest because of the missing table qualifer. The code may have to be changed elsewhere to get this fixed but I guess it would be the very same issue and it should be treated together with this one, doesn't it?
I mean... the problem seems to be "unqualified columns on multi-table queries with the joined subclass strategy", may it manifest on the WHERE clause or the ORDER BY clause.
> hql update generate wrong sql with joined subclass hierarcy
> -----------------------------------------------------------
>
> Key: HHH-1657
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Environment: Hibernate 3.2.0cr1, Hibernate 3.1.3
> Reporter: Alexey Romanchuk
> Assignee: Gail Badner
> Priority: Critical
> Fix For: 3.2.x, 3.3.0
>
>
> Let suppose that we have two joined subclass entities: Parent (id PK) and Child (id PK) that mapped with joined subclass method.
> When I try to update Child by id with hql:
> update Child c set c.field = 'value' where c.id = 1234
> hibernate generates joined tables like
> insert into HT_parent select child0_.id as id from child child0_ inner join parent child0_1_ on child0_.id=child0_1_.id wher id in = 1234
> look at last condition. hibernate use id WITH OUT tables alias that cause sql exception: column reference "id" is ambiguous
--
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
16 years, 8 months
[Hibernate-JIRA] Commented: (HHH-1657) hql update generate wrong sql with joined subclass hierarcy
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657?page=c... ]
Gail Badner commented on HHH-1657:
----------------------------------
Peter, thanks for the patch. I'm using it as a starting point.
It would really help if someone could provide a patch for some existing unit tests to reproduce this issue using multiple-table implementations of superclasses and subclasses.
In particular, I'm looking for tests that reproduce this issue with HQL using UPDATE and DELETE. I believe that the problem using "ORDER BY" is unrelated, but if someone wants to add tests that reproduce that issue, I'd take a look at that also.
The following test cases provide a good start:
org.hibernate.test.joinedsubclass.JoinedSubclassTest:
Table per subclass (<joined-subclass>)
org.hibernate.test.join.JoinTest:
Table per subclass, using a discriminator; superclass and subclasses both have join tables
org.hibernate.test.mixed.MixedTest:
Contains a subclass of a subclass in a separate table, using a discriminator
org.hibernate.test.unionsubclass2.UnionSubclassTest:
Table per concrete class
> hql update generate wrong sql with joined subclass hierarcy
> -----------------------------------------------------------
>
> Key: HHH-1657
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Environment: Hibernate 3.2.0cr1, Hibernate 3.1.3
> Reporter: Alexey Romanchuk
> Assignee: Gail Badner
> Priority: Critical
> Fix For: 3.2.x, 3.3.0
>
>
> Let suppose that we have two joined subclass entities: Parent (id PK) and Child (id PK) that mapped with joined subclass method.
> When I try to update Child by id with hql:
> update Child c set c.field = 'value' where c.id = 1234
> hibernate generates joined tables like
> insert into HT_parent select child0_.id as id from child child0_ inner join parent child0_1_ on child0_.id=child0_1_.id wher id in = 1234
> look at last condition. hibernate use id WITH OUT tables alias that cause sql exception: column reference "id" is ambiguous
--
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
16 years, 8 months