-->
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: Trouble with cascade
PostPosted: Thu Jul 21, 2005 1:53 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 12:49 pm
Posts: 34
Hey folks,

Figured out the problem as I wrote the post but it might help someone
of a similar brain dead persuasion.


I've set up a one-to-many relationship setup between my conversation and my message objects as follows
Code:
      <set name="messages" table="CONVERSATION_MESSAGE" cascade="save-update,delete">
         <key column="CONVERSATION_ID"/>
         <many-to-many column="MESSAGE_ID"
            unique="true"
            lazy="false"
            class="com.recorder.http.Message"/>
      </set>


Now when I add a few messages to a conversation and save, everythings
grand.

I reload the conversation and remove a message from the set.
Now I update the conversation in the db. session.update( .... )

Now the row in the join table has been deleted by the message has not.
This means I could have a huge message table building up upbeknownst to me because they're orphaned.... Ahhh is that the answer??

Stickin' in the delete-orphan attribute... Loading.... Saving...
Deleting... checking table..... Hah it worked. Bingo bango.

That's champion.

Great app ye have here. If I can understand it anyone can.

Thanks,
Mark.


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.