« Return to Thread: Create persistence unit programmically without persistence.xml

Re: Create persistence unit programmically without persistence.xml

by James Sutherland :: Rate this Message:

Reply to Author | View in Thread

I suppose that is the main reason you need a persistence.xml, to define the set of classes/classpath.  I don't think it is possible to deploy JPA without a persistence.xml.  You could log an enhancement to allow passing the class list, or orm.xml file with the persistence properties Map, but you would still need to access the EclipseLink provider directly as JPA Persistence requires a persistence.xml to know the provider.

You can create an EntityManagerFactory using an EclipseLink ServerSession, but then you would need to build the EclipseLink ClassDescriptors yourself or using the Mapping Workbench.  You could also try to use the MetadataProcessor directly yourself to process a set of annotations or orm.xml.


philk wrote:
Hello,

I want to create a persistence unit with out using the persistence.xml. I am
already feeding EL all the "eclipselink" properties for the database
connection and the class loader. The last thing I struggle to find is, how
to feed EL the entity classes that the PU should be aware of. How would I do
that?

Thanks,
Phil

 « Return to Thread: Create persistence unit programmically without persistence.xml