[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]
|