-->
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: Find parent for child entity
PostPosted: Fri Jan 20, 2012 6:29 am 
Newbie

Joined: Thu Jan 19, 2012 11:42 am
Posts: 1
Hi all,

how can i check if an entity has a parent entity which maps this entity over
Quote:
@OneToMany
annotation.
The mapping is unidirectional defined on the parent

Code:
@Entity
public class ParentEntity {

   ...

   @OneToMany(cascade=CascadeType.ALL)
   private Collection<ChildEntity> childEntities;
   
   ...


Hibernate automagically creates a mapping table, or if used
Code:
@JoinColumn
a column with the parent-id in the child table.
When the child gets persisted, hibernate adds the corresponding parent id to the db-table.

I do not want to define a bidirectional relation since i do not need this "feature" in my application-logic and there are already loads of entities which would need a change. I just need the parent for replication issues. This means i have to export some data to another DB schema (has different table structure).

I use an interceptor to trigger the replication action in the
Code:
onSave(...)
method defined by the Interceptor interface. If a parent gets a new child, there is just the persist action of the child triggering. I do not know the parent it belongs to.

I really appreciate any help!

Thanks!


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.