Hibernate version: 2.1
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo">
<class name="EI.Poco.PoParty, EI.Poco" table="Party">
<id name="Id" type="Int32" column="partyId">
<generator class="identity" />
</id>
<version name="Version" column="version" access="nosetter.camelcase"/>
<property name="DateFrom" column="dateFrom" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
<property name="DateTo" column="dateTo" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
<property name="IntroducerId" column="introducerId" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate" />
<bag name="PartyArchives" inverse="true">
<key column="partyId" />
<one-to-many class="EI.Poco.PoPartyArchive, EI.Poco" />
</bag>
<property name="PartyTypeId" column="partyTypeId" type="Byte" />
<property name="UpdatedByUsrId" column="updatedByUsrId" type="Int32" />
<property name="UpdatedDateTime" column="updatedDateTime" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" update="false" insert="false" access="nosetter.camelcase"/>
<joined-subclass name="EI.Poco.PoOrganisation, EI.Poco" table="Organisation">
<key column="partyId"/>
<property name="Established" column="established" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate"/>
<property name="OrgName" column="orgName" type="String" />
</joined-subclass>
<joined-subclass name="EI.Poco.PoPerson, EI.Poco" table="Person">
<key column="partyId"/>
<property name="AbiGenderId" column="abiGenderId" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate" />
<property name="DateOfBirth" column="dateOfBirth" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
<property name="AbiTitleId" column="abiTitleId" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate" />
<property name="Firstnames" column="firstnames" type="String" />
<property name="Initials" column="initials" type="String" />
<property name="Lastname" column="lastname" type="String" />
</joined-subclass>
</class>
</hibernate-mapping>
----------------------
Tables:
-Party
-PartyArchive
-Person
-PersonArchive
Question:
When any update is performed I would like to save the previous values to the archive tables.
I can achieve this using triggers, however the triggers cannot manage the foreign key relationship between the PartyArchive table and the PersonArchive table [PartyArchive.partyArchiveId=PersonArchive.partyArchiveId].
Can I customise the Hibernate Update to include an archive process?
Does anyone have any suggestions?
Regards
|