0

JPA is pretty good for immutable tables but I can't handle dynamic table.

Then I decide to use JPA for handle al the unalterable tables (the core of the application) and dbutils from apache to handle all my the dynamic tables

Both kind of tables are in the same database and I want to define the configuration of the database only in a single file

I define the jpa in a property file:

javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
javax.persistence.jdbc.user=root
javax.persistence.jdbc.password=*****
javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/database

But dbutils use the class "datasource" to configurate.

I didn't find how to get a "Datasource" from de "EntityManagerFactory" of jpa.

Or to get a instance of "EntityManagerFactory" from a "Datasource".

Troncador
  • 3,356
  • 3
  • 23
  • 40

1 Answers1

0

An EMF can be created for a (javax.sql.)DataSource by specifying the persistence-unit "jta-data-source" or "non-jta-data-source" (the JNDI name for the DataSource). So create the DataSource, make it accessible via JNDI, and then you can use it in the EMF and this "dbutils".

DataNucleus
  • 15,497
  • 3
  • 32
  • 37