I've been bumping my head on this problem and hope to find a solution here.
I have a "many-to-many" relation (Users -> UserState -> State)
A user can have many non-unique states which can change over time, defined in my intermediate table. (UserState)
I'm uncertain how I could gain acces to UserState.StateDate, which holds the moment the record was created.
Is there a way to map the column from the intermediate table to my State object or what would the most pragmatic way to gain access to the dates ?
Take a look at the bag
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="datatransfer" namespace="datatransfer">
<class name="datatransfer.User,datatransfer" table="Users">
<!-- Unsaved-value = insert vs. update id -->
<id name="ID" column="ID" type="int" unsaved-value="0">
<!-- What will generate new id's ?-->
<generator class="native"></generator>
</id>
<property name="Name" column="Name" type="string" length="50" not-null="false" />
<property name="FirstName" column="FirstName" type="string" length="50" not-null="false" />
<property name="Email" column="Email" type="string" length="50" not-null="false" />
<property name="Created" column="Created" type="DateTime" not-null="false" />
<bag name="States" table="UserState" lazy="false">
<key column="UserID" />
<many-to-many class="datatransfer.State,datatransfer" column="ID" fetch="join">
<column name="ID" />
</many-to-many>
</bag>
</class>
</hibernate-mapping>
Thanks for any pointers...