This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Entity in two persistence units Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Entity in two persistence units" Watch "Entity in two persistence units" New topic
Author

Entity in two persistence units

Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hi,

I have two persistence units in one persistence.xml
Each persistence unit connected with separate database and using Hibernate.
say Entitymanager em1 for persistence unit1 and
Entitymanager em2 for persistence unit2.
I get an entity from em1 using JPQL and it has values.
I want to persist this entity with em2.
I am getting an error "detached entity passed to persist."

Can some one post how do achieve this ?

Thanks
Kathir
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Did you try to merge the object with em2


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Yes, the merge is working fine.

thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Entity in two persistence units