I'd like to implement a typical M-to-N relationship, like book borrowing
Code:
user -> borrow <- book
|
borrowDate
where borrowDate should be an attribute in borrow table.
I manage to implement the M-to-N between user and book as:
Code:
<class name="Book" table="book">
<id name="id" column="id" type="int" unsaved-value="0" >
<generator class="assigned"/>
</id>
<set name="borrowers" table="borrow" inverse="false" cascade="none">
<key column="bookId"/>
<many-to-many class="User" column="borrowerId"/>
</set>
</class>
<class name="User" table="user">
<id name="id" column="id" type="int" unsaved-value="0" >
<generator class="assigned"/>
</id>
<set name="borrowedBooks" table="borrow" inverse="false" cascade="none">
<key column="borrowerId"/>
<many-to-many class="Book" column="bookId"/>
</set>
</class>
but have no idea on dealing with the borrowDate. Any clue?