Announcement Announcement Module
No announcement yet.
JPA: Multiple (dynamic) datasources/EMF? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPA: Multiple (dynamic) datasources/EMF?

    I'm trying to figure out how to accomplish having multiple datasources/databases with JPA. Our system currently has a single database and EMF (hibernate as the provider). In the system there are Client entity beans, which we have given a String attribute holding a JNDI datasource name. We now want to be able to use that to dynamically create a new EMF with the jndi name as the datasource, so we can connect a Client to its Order entity beans.

    So basically this means the ability to somehow create an EMF (or tell the existing EMF about a new DSN) to load up Order entity beans from a database. Is anything like this even possible? The whole kicker here is the Clients are defined by users in the system, so we can't just list all the datasources in spring xml, but rather create them dynamically at run time.

    Any help is greatly appreciated!