[jboss-user] [JBoss Seam] - Dynamic data sources with EntityManager

wiberto do-not-reply at jboss.com
Thu Aug 2 14:31:42 EDT 2007


I have an application where the data source it uses is saved in the database. This is because each user can have its own data source.

So UserA will have an entry in it's user information table that says to use data source jdbc/UserA.

Lets assume that this entry is already configured in the app server itself.

How do I tell the EntityManager at runtime to use that datasource.

If this was a static configuration I know I will have the persistence unit defined in my persistence.xml file and I would set the annotation in my entity. Something like this


  | @PersistenceContext(unitName="userAunit")
  | private EntityManager em;
  | 



So how do I make this generic? Do I need to override any EntityManager API to be able to select the unitName at run time? Also, can I create persistence units on the fly?

Thanks in advanced,

Jose 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070241#4070241

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4070241



More information about the jboss-user mailing list