-->
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: transitive persist associations only?
PostPosted: Sun Jan 30, 2011 1:51 pm 
Newbie

Joined: Sun Jan 30, 2011 1:41 pm
Posts: 2
I have a one-to-many relationship between class Parent and class Child. Child instances can be persisted without a parent (they can be orphaned). I have the following tables (simplified):

table 'parent': integer id
table 'parent_children': integer parent_id, integer child_id
table 'children': integer id

However, I have a complex 'child' class and saving/loading involves spanning multiple data sources. As such, I would like to have hibernate manage 'parent' and the relationships between the parent and its children, but I don't actually want to enable transitive persistence for the Child instances themselves; only the relationship between the two. However, I would still like to be able to load the full graph when loading a 'parent' object.

Is this possible via hibernate? Is there any way to manage associations without cascading all the way down to the child entities?
I would welcome any workarounds as well. I'm using external hibernate mapping files (.hbm.xml) rather than annotations.


Top
 Profile  
 
 Post subject: Re: transitive persist associations only?
PostPosted: Sun Jan 30, 2011 1:58 pm 
Newbie

Joined: Sun Jan 30, 2011 1:41 pm
Posts: 2
It occurs to me I could define the association as a one-to-many mapping between Parent and a collection of the simple type of the id. I would have to manage loading/saving of Child objects manually (which is what I want) but hibernate could then handle the transitive nature of just the Ids.


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.