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: Using cascade styles for unidirectional associations?
PostPosted: Thu Aug 31, 2006 7:07 pm 
Newbie

Joined: Fri Nov 04, 2005 11:42 am
Posts: 13
Hi

I have a question regarding cascading styles when used for unidirectional associations. Say, I have object X and object Y such that X has a one-to-many association with Y, its unidirectional, so Y doesnt have a back reference to X object. That gives me a table for X object and a table for object Y with a column for x_id, right.

If I already have an instance x1 for Object X saved in the database. Now, I want to add a new y1 instance of Object Y to x1. The only way I got it working was to:
(1) get the x1 instance from the database.
(2) create y1 and add it to x1 {x1.add(y1)}
(3) save(y1)
(4) update(x1)

Can this be achieved using any of the cascade styles. I tried using both save and update but that doesnt work. With cascade "save-update" if I update the x1 after adding y1 to it, hibernate tries to update a y1 object that doesnt even exist and if I save x1 after adding y1 to it, hibernate obvioulsy tries to resave the x1 object to the database.

If I cannot do what I am doing with cascade styles, is there any other way besides the one I did, to achieve the same thing?

Thanks a lot,
Neha.


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.