I have a situation where I want to introduce a history table for each
table / data item that I currently store in my database. In my current
database schema all child object have a foreign key to their parent
(they know the id to the parent, as demonstrated in the mapping
below). The id of each object is in the current model the primary key
of the table.
Now in the history table the primary key would be changed for each
object into a composite key (id + version/datetimestamp). There are
two approaches I can think of to be able to support querying on the
history tables while maintaining my original nhibernate business
objects:
1: Somehow pass the version number to each relation resolve (join) to
determine which version of the relation should be retrieved so that
nhibernate can create a model for it automatically and resolve all
references.
2: Define no foreign keys on the history tables and create custom
queries to get data from the history tables
For both approaches, I do not know how to pass the version to each
relation/join automatically or how to adept my nhibernate mapping to
realize this.
Any suggestions for realizaing this in my mappings and pro's/cons
between the two approaches are greatly appreciated. My knowledge is
mostly based on nhibernate 1.2.0, so it could be I am not aware of new
functionality in nhibernate 2.2 / 3. My search efforts have not helped
me much for this problem.
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="RailroadCompany, Rails.Services.Bo"
table="RLS_RAILROAD_COMPANY">
<id name="Id" column="RAILROAD_COMPANY_ID" type="string"
length="15" unsaved-value="">
<generator class="BusinessObjectIdGenerator, Framework.Bo" ></
generator>
</id>
<version name="Version" column="RAILROAD_COMPANY_VERSION"
type="int"/>
<property name="Name" column="NAME" length="255" type="string" />
<property name="CreatedBy" column="CREATED_BY" type="string" />
<property name="LastUpdatedBy" column="LAST_UPD_BY"
type="string" /
>
<property name="OrganizationId" column="ORG_ID" length="15"
type="string" />
<property name="FoundationDate" column="FOUNDATION_DATE"
type="System.DateTime" />
<property name="Created" column="CREATED"
type="System.DateTime" />
<property name="LastUpdated" column="LAST_UPD"
type="System.DateTime" />
<bag name="TrainList" cascade="all" lazy="true" inverse="true"
>
<key column="RAILROAD_COMPANY_ID"/>
<one-to-many class="Rails.Services.Bo.Train,
Rails.Services.Bo"/>
</bag>
</class>
</hibernate-mapping>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.