I have a parent table, t_books_category and a corresponding child table T_Book with a 1-n mapping. My configuration files for the two tables are as under:
Mapping for T_BOOKS tableCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="domainObject.Book" schema="super" table="t_books">
<id name="bookId" column="book_id" type="long">
<generator class="sequence">
<param name="sequence">SEQ_ID</param>
</generator>
</id>
<property name="bookName" column="book_name" type="string" />
<property name="categoryDate" column="cat_date" type="date" />
<many-to-one name="booksCategory" class="domainObject.Category">
<column name="cat_id" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
Mapping for T_BOOKS_CATEGORYCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="domainObject.Category" table="t_books_category"
schema="super">
<id name="categoryId" column="cat_id" type="long">
<generator class="sequence">
<param name="sequence">seq_id</param>
</generator>
</id>
<property name="categoryName" type="string" column="cat_name" />
<property name="categoryDate" type="date" column="cat_date" />
<set name="books" inverse="true" cascade="save-update,delete,delete-orphan">
<key column="cat_id" />
<one-to-many class="domainObject.Book" />
</set>
</class>
</hibernate-mapping>
As you can see I have been able to map the foreign key attribute of cat_id. However there is one further requirement, there is an additional column cat_Date which is also present in the child table and both values will be the same. However this field is a non key field in both the tables. How do i perform the mapping for this column such that save and update on the master table is cascaded to the child table too.
Thank you and I would appreciate any help.