Programming <class> Definitions in EclipseLink

I am trying to use EclipseLink in an OSGi environment.

What I want to do is create a provider package that exposes the EntityManager to other bindings.

The problem is that entity classes cannot be defined and written to the persistence.xml file at compile time. So I want to be able to define entity classes programmatically. I can scan all the Entity classes, but as far as I could see there is no way to define it in EclipseLink, while it is possible in Hibernate. (Hibernate has some other issues in the OSGi environment, so I cannot use it).

How can I define classes of objects programmatically?

Note. Using spring is not an option for me; and defining ClassDescriptors from scratch is not allowed. I have to say that it is really silly that such an essential feature is not supported directly in JPA or EclipseLink.

+3


source to share


2 answers


Have you tried the tag <jar-file>

in persistence.xml?

you can package all your persistence classes in jar, include it in your set of persistence units and persistence xml.



more details in JPA2 spec 8.2.1.6.3

+1


source


Have you tried this?



<exclude-unlisted-classes>false<exclude-unlisted-classes>

      

+1


source







All Articles