I have an "Attachment" persistent class, that can be attached to multiple parent classes.
We decided to use an <any> mapping to identify the parent of the Attachment (we evaluated using inheritance, but it'll complicate class hierarchy quite a bit).
In Hibernate 2.1.8 everything worked well.
In Hibernate 3.0rc1, SchemaExport generate wrong foreign key constraints, one for any possible destination of the <any> mapping:
alter table ATTACHMENT add constraint FKA7E14523E1190749 foreign key (PARENT_FK) references WPR
alter table ATTACHMENT add constraint FKA7E14523CDF83409 foreign key (PARENT_FK) references PROJECT
It doesn't happens if I remove the inverse mapping in Project and WorkProgressReport, but I need inverse mappings.
It's not possible to have an inverse association for <any> mappings?
Hibernate version: 3.0 rc1
Mapping documents:
Attachment.xml
...
<any name="parent" id-type="int" meta-type="string">
<meta-value value="PJT" class="mymodel.ARITpm.hibernate.Project"/>
<meta-value value="WPR" class="mymodel.ARITpm.hibernate.WorkProgressReport"/>
<column name="PARENT_TYPE" not-null="true"/>
<column name="PARENT_FK" not-null="true"/>
</any>
...
WorkProgressReport.xml and Project.xml
...
<set
name="attachments"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
>
<key
column="PARENT_FK"
/>
<one-to-many
class="mymodel.ARITpm.hibernate.Attachment"
/>
</set>
...
Name and version of the database you are using: Oracle 10g
|