-->
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: Relationship of two entity's with two different PU's
PostPosted: Wed Aug 24, 2011 1:16 pm 
Newbie

Joined: Wed Aug 24, 2011 12:22 pm
Posts: 1
Hello everybody!

First of all, sorry if my english is poor, i'm brazilian and i'm not used to post in international forums.

Well, i have a problem and i'd like to know if you can help me.

Let's go:
I'm using JPA2 and i have two Persistence Units:

Code:
<persistence-unit name="PU1"> 
        <class>br.com.maua.entity.Client</class>   
</persistence-unit> 


Code:
<persistence-unit name="PU2"> 
        <class>br.com.maua.entity.Account</class>   
</persistence-unit> 


A Client can have any number of Accounts, so here we have a @OneToMany relationship. But how you can notice above, they are in different Persistence Unit's, and when i do the deploy, the following exception is throw:

Quote:
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class


This exception is throw because they are in different PU's, right. So, i found this solution:
http://stackoverflow.com/questions/4902215/hiberna...nk-between-2-persistence-units

But the problem is that when i persist an Account that belongs to a Client, the Client entity is created in the persistence unit that belongs to Account , and i don't wanna that it happens because the Client information must stay only in your persistence unit.

So, here we go with the question: There's a way to create a relationship between two entitys with different persistence units?

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.