|[JPA] Initializing a persistence unit with information retrieved at runtime [message #638294]
||Wed, 10 November 2010 18:01
| Alexandros Karypidis
Registered: March 2010
I am using EclipseLink in a JavaSE application, in which I need to initialize a persistence unit from a JAR that is loaded at runtime, but does NOT have a persistence.xml.
So, for example, suppose I have a class loader for "myentitites.jar", which does NOT include a META-INF/persistence.xml file. Suppose also that even though the persistence.xml is missing, I somehow have all the required values in a runtime Object (e.g. puInfo). How do I get from that to creating an EntityManagerFactory? I've tried:
factory = new PersistenceProvider().createEntityManagerFactory(puInfo.getName(), properties);
However, EclipseLink returns a null object for the EntityManagerFactory without logging some error or throwing an exception...
1st edit: I use EclipseLink in an OSGi environment (using the Rich Ajax Platform).
2nd edit: I should point out that I don't care about using EclipseLink-specific APIs to achieve this. So although I would use JPA in the rest of the code, it's ok to create my EntityManagerFactory using non-standard APIs.
[Updated on: Wed, 10 November 2010 18:08]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01773 seconds