| Summary: | Support Mandatory One-To-One relations with Hibernate | ||
|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Hans Meier <eclipseBugs> |
| Component: | Teneo | Assignee: | Martin Taal <mtaal> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Hans Meier
I did some further investigations on this issue. The problem is the combination of cascade="all" and constrained="true" in the one-to-one tag of generated hibernate mapping. <hibernate-mapping auto-import="false"> <class name="demo.impl.AnimalImpl" entity-name="Animal" abstract="false" lazy="false" table="`Animal`"> <meta attribute="eclassName">Animal</meta> <meta attribute="epackage">http://demo</meta> <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> <meta attribute="syntheticId">true</meta> <generator class="native"/> </id> <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> <meta attribute="syntheticVersion">true</meta> </version> <one-to-one name="head" entity-name="Head" cascade="all" lazy="false" property-ref="animal" constrained="true"/> </class> <class name="demo.impl.HeadImpl" entity-name="Head" abstract="false" lazy="false" table="`Head`"> <meta attribute="eclassName">Head</meta> <meta attribute="epackage">http://demo</meta> <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> <meta attribute="syntheticId">true</meta> <generator class="native"/> </id> <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> <meta attribute="syntheticVersion">true</meta> </version> <many-to-one name="animal" entity-name="Animal" cascade="merge,persist,save-update,lock,refresh" not-null="true" lazy="false" insert="true" update="true" unique="true"/> </class> </hibernate-mapping> To me this looks like a bug in hibernate. But since the underlying ORM should be transparent to the Teneo users a workaround is needed. E.g. by setting the constrained="true" to "false" and doing the validation of the mandatory 1-1 reference in Teneo some how. |