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: Different EntityManagers - problems
PostPosted: Mon Mar 30, 2009 1:38 pm 
Newbie

Joined: Mon Nov 14, 2005 5:17 am
Posts: 13
Hello,

I am having a situation where sometimes I would like to override the EntityManager (by setting a new one manually) over the one that was injected automatically by Jboss AS,


So I don't use the '@PersistenceContext', but instead I use:
Code:
@PersistenceUnit
private EntityManagerFactory factory;


And factory the entity manager when necessary by: factory.createEntityManager();

Apparently, the behavior is different, as I started to get exceptions such as:

Quote:
A detached entity passed to persist


I assume that somehow the AS is smart enough to inject the right EM even though I use different EJBs for loading/persisting.


Is there a correct way to create entity managers as the AS would do as when using 'PersistenceContext' ? maybe the factory is not the right way here.



Many thanks,


Asaf.


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.