-->
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.  [ 3 posts ] 
Author Message
 Post subject: initial saving of complex objects
PostPosted: Thu Oct 27, 2005 7:59 am 
Newbie

Joined: Thu Oct 27, 2005 7:51 am
Posts: 9
Location: Germany
Hibernate version: 3

Hello,

i tried hibernate and i am very impressed. Nice work.

But during my tests i had one problem.

I have a complex structure of an object which have several (joined-)subclasses and many assoziations.

When i create such an object an i want to save it, then i call
Code:
session.save(myObject);


But the assoziations arn't saved automatically.
I have to save them manually by calling the save-Method fpr each assoziation.
Code:
session.save(myObject);
session.save(myObject.getAssoziation1();
session.save(myObject.getAssoziation2();


Is there a nicer way to do this?
Can Hibernate save the Assoziations by itself?

Sorry, i this topic is discussed elsewhere, but i didn't find it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 10:14 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 8:22 pm
Posts: 48
Take a look at the cascade property in the manual. It controls if Hibernate automatically checks to see if associated objects need to be saved. You can see it here on the one-to-one mapping.

http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-onetoone


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 2:17 am 
Newbie

Joined: Thu Oct 27, 2005 7:51 am
Posts: 9
Location: Germany
ahhh Thanks.

if you know what are you searching then you are able to find it ;-)


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

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.