retrieve problem when using <join table clause
----------------------------------------------
Key: HHH-6152
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6152
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria, query-hql
Affects Versions: 3.2.7
Environment: Hibernate 3.2.7, Oracle 10g database
Reporter: Sathya Balakrishnan
I have inheritance relation modeled.
class SuperClass
name
type
Order order;
class SubClass extends SuperClass
attr1
attr2
etc
in the mapping. I have mapped SubClass in SubClass.hbm.xml and used <join table
<join table="Super_CLASS">
<key column="ID" />
<many-to-one name="order" class="MyOrder" />
SubClass further has SubSubClass1 SubSubClass2 and modeled using subclass and
discriminators. My database model is
there is one SUPER_CLASS table and many SUB_CLASS tables and within one branch of
hierarchy there can be many child classes.
Another main class - Order class which contains all the subclasses.
MyOrder
List<SubClass> subClassList
mapping is done with bag
<bag name="subClassList" table="SUB_CLASS"
inverse="true" cascade="all">
<key column="order_id"
<one-to-many class="SubClass" />
</bag>
Now the problem is while retrieving when we traverse the class MyOrder and call
getSubClassList() hibernate fires a query to pull this entity but the query generated is
using the order_id to query this entity which is correct but
the query generated expects the order_id to be present in SubClass tables alias instead of
SuperClass table alias.
for eg : generate query- select subclass_1.order_id, subclass_1.attr1, subclass_1.attr2,
superclass_1.name, superclass_2.type ...
from SUB_CLASS subclass_1 INNER JOIN SUPER_CLASS superclass_1
ON subclass_1.id = superclass_1.id
WHERE subclass_1.order_id = ?
order_id field is expected to be found in subclass_1 ( SUB_CLASS ) - This is causing the
failure.
How to over come this ?.
Thanks,
Sathya.
--
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