You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Akash Gunjal <ak...@in.ibm.com> on 2013/10/17 19:23:06 UTC

Persisting an entity managed by a different entity manager

Hello,

I am facing a transaction issue with the entity manager injected using
blueprint.xml. There are 2 persistence bundles each managing different
entities. For instance, the entity1 managed by entityManager1 holds an
entity2 managed by entityManager2. So when the entityManager1 tries to
persist its entity1, the I get an error since internally entity1 holds
entity2 which cannot be persisted by entityManager1.

The solution to this is to detach the entity2 from the entityManager2. But
since the entity managers are loaded through persistence units by using JPA
annotation @PersistenceContext, this detaching cannot be done. So what
could be the alternate solution to this issue.

Regards,
Akash


Re: Persisting an entity managed by a different entity manager

Posted by Rick Curtis <cu...@gmail.com>.
I don't know if I entirely follow your post, but why can't you detach the
Entity from one EntityManager and merge it into the other?


On Thu, Oct 17, 2013 at 12:23 PM, Akash Gunjal <ak...@in.ibm.com> wrote:

>
> Hello,
>
> I am facing a transaction issue with the entity manager injected using
> blueprint.xml. There are 2 persistence bundles each managing different
> entities. For instance, the entity1 managed by entityManager1 holds an
> entity2 managed by entityManager2. So when the entityManager1 tries to
> persist its entity1, the I get an error since internally entity1 holds
> entity2 which cannot be persisted by entityManager1.
>
> The solution to this is to detach the entity2 from the entityManager2. But
> since the entity managers are loaded through persistence units by using JPA
> annotation @PersistenceContext, this detaching cannot be done. So what
> could be the alternate solution to this issue.
>
> Regards,
> Akash
>
>


-- 
*Rick Curtis*