adam77 wrote:
Hi,
I'm having a similar problem. Please see my post:
http://forum.hibernate.org/viewtopic.php?t=968743Sorry, no solution so far :-(
I have a solution. For a list with index you need a key for this index:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"./etc/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.eye.hibernate">
<class name="DaySchedule" table="DAY_SCHEDULE">
<cache usage="read-write"/>
<composite-id>
<key-many-to-one name="weekSchedule" column="WEEK_SCHEDULE_ID" class="WeekSchedule"/>
<key-property name="DayOfWeek" column="DAY_OF_WEEK"/>
</composite-id>
<version name="version" column="VERSION" unsaved-value="undefined"/>
<property name="DayScheduleName" column="DAY_SCHEDULE_NAME"/>
<list name="Periods" inverse="true" cascade="all-delete-orphan">
<key>
<column name="WEEK_SCHEDULE_ID"/>
<column name="DAY_OF_WEEK"/>
</key>
<index column="PERIOD_ID"/>
<one-to-many class="Period"/>
</list>
<property name="Active" column="ACTIVE"/>
</class>
</hibernate-mapping>
****************************************************
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"./etc/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.eye.hibernate">
<class name="WeekSchedule" table="WEEK_SCHEDULE">
<cache usage="read-write"/>
<id name="Id" type="int" column="ID">
<generator class="native"/>
</id>
<list name="DaySchedules" inverse="true" cascade="all-delete-orphan" lazy="true">
<cache usage="read-write"/>
<key column="WEEK_SCHEDULE_ID"/>
<index column="DAY_OF_WEEK"/>
<one-to-many class="DaySchedule"/>
</list>
<property name="WeekScheduleID" column="WEEK_SCHEDULE_ID"/>
<property name="WeekScheduleName" column="WEEK_SCHEDULE_NAME"/>
<property name="Active" column="ACTIVE"/>
<set name="WeekScheduleInFpus" inverse="true" cascade="all-delete-orphan" lazy="true">
<cache usage="read-write"/>
<key column="WEEK_SCHEDULE_ID"/>
<one-to-many class="WeekScheduleInFpu"/>
</set>
</class>
</hibernate-mapping>