-->
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.  [ 2 posts ] 
Author Message
 Post subject: auto save fk?
PostPosted: Mon Sep 13, 2004 6:20 am 
Newbie

Joined: Mon Sep 13, 2004 3:40 am
Posts: 2
[b]Hibernate version:2.6.1[/b]
I have one to many relationship. I know Hibernate can save Collection automatically, But is there any way, Hibernate can automatic save fk without explicity call
child.setParent(parent); //which cause terator each child in Parent again, just for set the relationship

I like just pass a Parent with Child Colletion. Then it can save all relationship.
public void saveAll(Parent parent){
session.save(parent);
}

[b]Mapping documents:[/b]
Parent:
<set
name="childs"
lazy="true"
inverse="true"
cascade="save-update"
>
<key>
<column name="parentId" />
</key>
<one-to-many
class="com.netsboss.marsrover.biz.hibernate.Child"
/>
</set>

Child
<many-to-one
name="airItinerary"
class="com.netsboss.marsrover.biz.hibernate.Parent"
not-null="true"
>
<column name="parentId" />
</many-to-one>

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 13, 2004 1:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I strongly recommand you to reread the reference guide or Hibernate In action.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.