[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6177) Envers - problem with mapping relation when using mixed inheritance strategy
Michał Skowronek (JIRA)
noreply at atlassian.com
Sun May 1 10:35:59 EDT 2011
Envers - problem with mapping relation when using mixed inheritance strategy
----------------------------------------------------------------------------
Key: HHH-6177
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6177
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 4.0.0.Alpha2
Environment: 3.6.0.Final
Oracle10g
Reporter: Michał Skowronek
Attachments: MixedInheritanceStrategies.patch
For the mapping like that:
<hibernate-mapping>
<class abstract="true" name="AbstractActivity"
table="ACTIVITY">
<id name="id" type="integer">
<generator class="assigned"/>
</id>
<discriminator column="ACTIVITY_TYPE" type="string" length="20"/>
<property name="sequenceNumber" type="int" not-null="true"/>
<subclass abstract="true"
name="AbstractCheckActivity">
<join table="ACTIVITY_CHECK">
<key foreign-key="FK_CHKACT_ACT" not-null="true" column="ACTIVITY_ID"/>
<property name="durationInMinutes" type="int" not-null="true" column="DURATION_IN_MINUTES"/>
<many-to-one name="relatedActivity"
cascade="merge"
foreign-key="FK_CHKACT_RELACT"
class="AbstractActivity"
lazy="proxy">
<column name="RELATED_ACTIVITY_ID" not-null="false"/>
</many-to-one>
</join>
<subclass name="CheckInActivity"
discriminator-value="CHECK_IN"/>
</subclass>
<subclass name="NormalActivity"
discriminator-value="NORMAL"/>
</class>
</hibernate-mapping>
Envers generates improper audit table configuration for AbstractCheckActivity:
<hibernate-mapping auto-import="false">
<subclass entity-name="AbstractCheckActivity_AUD" discriminator-value="AbstractCheckActivity" table="ACTIVITY_AUD" extends="AbstractActivity_AUD">
<join table="ACTIVITY_CHECK_AUD">
<key>
<column name="ACTIVITY_ID" length="255" scale="2" precision="19"/>
<column name="REV"/>
</key>
<property name="durationInMinutes" insert="true" update="false" type="integer">
<column name="DURATION_IN_MINUTES" length="255" scale="2" precision="19"/>
</property>
<properties name="relatedActivity">
<property name="relatedActivity_id" insert="true" update="false" type="integer">
<column name="RELATED_ACTIVITY_ID" length="255" scale="2" precision="19"/>
</property>
</properties>
</join>
</subclass>
</hibernate-mapping>
This is not a valid mapping document, because properties tag is not allowed within join. The resulting schema doesn't contain column RELATED_ACTIVITY_ID -> this property is always null for historic data (as read by AuditReader).
The problem won't occur if I use joined-subclass inheritance strategy for the hierarchy, but it's not desirable here.
--
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list