I try to develop a Java Plugin application using the Java plugin framework. All plugins will have acces to a uniq database using JPA (with Eclipselink).
But each plugin will have there own Entities.
So I could not declare all Entities in one unique file persitence.xml in the core plugin.
The question is: is it possible to declare Entity class on the fly when declaring the EntityManagerFactory? I am already using a Map to get connection string and user/password from user configuration file.
Is there a way to do the same with Entities ?
Map<String, String> p = new HashMap<String, String>();
p.put("javax.persistence.jdbc.url", dns);
p.put("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
p.put("javax.persistence.jdbc.user", config.getProperty("com.cjrf.xbmo.db.username", ""));
p.put("javax.persistence.jdbc.password", config.getProperty("com.cjrf.xbmo.db.password", ""));
entityManagerFactory = Persistence.createEntityManagerFactory("mediamanager", p);
Thanks for your help.
If your only concern is not do declare the class files in the persistence.xml then you can use auto detect funcionality.
For eclipselink add this to persistence.xml
Now all annotation mapped with
@Entity
will be scanned automatically.