[jboss-user] [EJB3] - Dinamically switch DataSource in EJB3 application

Sergei Makarov do-not-reply at jboss.com
Fri Dec 3 04:59:52 EST 2010


Sergei Makarov [http://community.jboss.org/people/sergerus] created the discussion

"Dinamically switch DataSource in EJB3 application"

To view the discussion, visit: http://community.jboss.org/message/574221#574221

--------------------------------------------------------------
Is there a way to dinamically switch EntityManager's DataSource to working with more then one datanase? For this time I found only way described here:

 http:// http://community.jboss.org/message/356772

+" mailto:bill.burke at jboss.com bill.burke at jboss.com" wrote:
deploy your entities as you would but assign them a JNDI name(see docs). In your EJB interceptor pick the appropriate JNDI name of the EntityManager you want to access. Either inject the ENtityManager into the field of your bean using a custom annotation, or stuff the chosen entity manager into a java.lang.ThreadLocal. This way you still get the automatic session management that the EJB/Java Persistence integration gives you. Following me?+
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/574221#574221]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101203/74d71ab8/attachment.html 


More information about the jboss-user mailing list