Hibernate version:3.1.3
I've got the following hibernate mappings defined:
Code:
<hibernate-mapping>
<class name="Card" table="Cards">
<id column="CardId" name="cardId" type="integer" >
<generator class="native" />
</id>
<property column="Name" lazy="false" name="name" not-null="true" type="string" />
<component name="auditData" class="AuditData">
<property column="DateCreated" name="dateCreated" type="timestamp" not-null="true" length="10" />
<property column="DateUpdated" name="dateUpdated" type="timestamp" not-null="true" length="10" />
<property column="UpdatedBy" name="updatedBy" type="integer" not-null="true" length="11" />
</component>
<list name="cardContents" lazy="false" cascade="all,delete-orphan" table="CardToCardContents">
<key column="CardId" />
<list-index column="Position" />
<many-to-many column="CardContentId" unique="true" class="CardContent" />
</list>
</class>
</hibernate-mapping>
and:
Code:
<hibernate-mapping >
<class name="CardContent" table="CardContents" lazy="false">
<id column="CardContentId" name="cardContentId" type="integer" >
<generator class="native" />
</id>
<property column="Content" name="content" not-null="true" type="string" />
<component name="auditData" class="AuditData">
<property column="DateCreated" name="dateCreated" type="timestamp" not-null="true" length="10" />
<property column="DateUpdated" name="dateUpdated" type="timestamp" not-null="true" length="10" />
<property column="UpdatedBy" name="updatedBy" type="integer" not-null="true" length="11" />
</component>
<many-to-one name="contentType" class="ContentType" column="ContentTypeId" lazy="false" cascade="none" />
</class>
</hibernate-mapping>
And the following tables defined:
Code:
Card Table:
CardId - int
Name - varchar(255)
DateCreated - date
DateUpdated - date
UpdatedBy - int
CardContents Table:
CardContentId - int
Content - varchar(255)
ContentTypeId - int
DateCreated - date
DateUpdated - date
UpdatedBy - int
CardToCardContents Table:
CardId - int
CardContentId - int
Position - int
My problem is when i save a Card, the Card and the CardContent tables are updated, but the association table,
CardToCardContents is empty. For whatever reason Hibernate will use the join table on fetching, but not on updating.
Can someone tell me what am i doing wrong? Thanks.
-B