Foreign key constraint should not be generated when <any> is used as element in a
collection
--------------------------------------------------------------------------------------------
Key: HHH-3889
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3889
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.0.SP1
Environment: hibernate verson = 3.3.0.sp1, db=h2
Reporter: Rice Yeh
Let P0, P1 and C are 3 classes. Both P0 and P1 have a set of C.
This is like parent-child relationship. In C, there is a field p
with type I, which is a interface shared by P0 and P1. These 3 classes are like below:
class P0 implements I {
Long oid;
Set<C> cs;
...
}
class P1 implements I {
Long oid;
Set<C> cs;
...
}
class C {
I p;
..
}
Their hbm mappings are like the following:
<class name="P0">
<id name="oid" type="java.lang.Long">
<generator class="native"/>
</id>
<set name="cs" cascade="all,delete-orphan"
inverse="true">
<key column="P_OID" not-null="true"/>
<one-to-many class="C"/>
</set>
</class>
<class name="P1">
<id name="oid" type="java.lang.Long">
<generator class="native"/>
</id>
<set name="cs" cascade="all,delete-orphan"
inverse="true">
<key column="P_OID" not-null="true"/>
<one-to-many class="C"/>
</set>
</class>
<class name="C">
<id name="oid" type="java.lang.Long">
<generator class="native"/>
</id>
<any name="p" meta-type="string" id-type="long">
<column name="P_CLASS"/>
<column name="P_OID"/>
</any>
</class>
Then 2 foreign key constraints F0 and F1 for P_OID in C to P0 and P1
are created when generated DDL respectively. This is not right
because persisting a object p0 in P0 will violate the constraint F1
and persisting a object p1 in P1 will violate the constraint F0.
--
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