-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Join table not being updated
PostPosted: Sun Oct 07, 2007 12:43 pm 
Beginner
Beginner

Joined: Tue Apr 24, 2007 12:53 pm
Posts: 28
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.