Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi!!
I am upgrading a large project to use hibernate3 (woeked with hibernate-2.1.7).
I have an any-mapping in my project that looks like that:
<any name="parent" meta-type="string" id-type="long" cascade="save-update" >
<meta-value value="com.mercury.dashboard.model.module.Module" class="com.mercury.dashboard.model.module.Module"/>
<meta-value value="com.mercury.dashboard.model.portletdef.PortletDefinition" class="com.mercury.dashboard.model.portletdef.PortletDefinition"/>
...
<column name="PARENT_ENTITY_NAME" not-null="true" length="200" unique="false" />
<column name="PARENT_PRIMARY_KEY" not-null="true" unique="false" />
</any>
The mapping on the other side (in Module and PortletDefinition xml's) look like that:
<set
name="authorizedUsers"
table="DSH_AUTHORIZED_USERS"
lazy="true"
inverse="true"
cascade="all"
sort="unsorted"
where="parent_entity_name = 'com.mercury.dashboard.model.module.Module'"
>
<key
>
<column name="PARENT_PRIMARY_KEY"/>
</key>
<one-to-many
class="com.mercury.dashboard.model.access.AuthorizedUser"
/>
</set>
and a similar thing for PortletDefinition...
Now, the problem is that schemaexport creates TWO different foreign key constrains on the same table and on the same column that make it impossible to add entries to this table - these are the created constraints:
alter table DSH_AUTHORIZED_USERS add constraint FK48AC982AE790DD7E foreign key (PARENT_PRIMARY_KEY) references DSH_PORTLET_DEFS;
alter table DSH_AUTHORIZED_USERS add constraint FK48AC982AB130BA34 foreign key (PARENT_PRIMARY_KEY) references DSH_MODULES;
Is it possible to ommit these constraints somehow? BTW, the old version did not add these foreign key constraints!!!
Thanks
Hibernate version:
hibernate-3.0.4