wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Creating JPA persistence unit without persistence.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Creating JPA persistence unit without persistence.xml" Watch "Creating JPA persistence unit without persistence.xml" New topic

Creating JPA persistence unit without persistence.xml

Hordur Thordarson

Joined: Feb 28, 2011
Posts: 1

I have been googling this problem forever now but have not found a solution, hopefully someone here can help (or tell me that it can't be done).

I have a JavaEE6 app that needs to connect to one or more databases which it does not know about at compile/deploy time.
A connection pool has been defined for each database in the application server the JavaEE6 app is deployed on (Glassfish 3.0.1) and each connection pool has a JNDI name like jdbc/db1, jdbc/db2 and so on.

Normally one would just create a simple persistence.xml file with persistence unit definitions for the databases and be done with it, but that won't work for this scenario because the JavaEE6 app gets set up at different clients that have different databases.

On the client side, I have a Adobe Flex application which has a client/database specific UI for querying these databases and this app needs to be able to send a query to the JavaEE6 app asking it to run a certain query against a certain database.

There is no ORM involved, I'm just using JPA native queries, and as I said, datasources for any databases are available in the app server via JNDI. The only thing I need is to be able to add persistence units dynamically because I don't want to have to create and package a different persistence.xml file for each client.

Does anyone have a solution to this problem or can this simply not be done with JavaEE/JPA ?

Thanks in advance,

I agree. Here's the link: http://aspose.com/file-tools
subject: Creating JPA persistence unit without persistence.xml
Similar Threads
toplink.jdbc.url ignored in persistence.xml
Sun Certified JPA Developer for the JavaEE6 Platform Beta
Persistence.xml | No JNDI Datasource
jpa, datasource and tomcat
[JPA 2.0] Redoploying app deletes my database?