2

I am trying to use EclipseLink in OSGi environment.

What I want to do is, building a provider bundle that exposes EntityManager to other bundles.

The problem is, entity classes can not be determined and written to persistence.xml file at compile time. So I want to be able to define entity classes programmatically. I can scan for all 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 different issues in OSGi environment, so I can not use it either)

How can I define entity classes programmatically ?

Note: Using spring is not an option for me; and defining ClassDescriptors from scratch is not acceptible. I must say that it is really stupid that such an essential feature is not supported neither in JPA nor EclipseLink directly.

koders
  • 5,654
  • 1
  • 25
  • 20

2 Answers2

1

did you try <jar-file> tag in persistence.xml?

you can pack all your persistence classes into jar, include it into your persistence unit bundle and persistence xml.

more details in JPA2 spec 8.2.1.6.3

Dmytro Pishchukhin
  • 2,369
  • 1
  • 14
  • 19
  • If I could do that, I could also add class names to the persistence.xml file. Any bundle can have its persistence classes and they can not be merged into a single one. – koders Mar 19 '12 at 18:55
1

Did you try this?

<exclude-unlisted-classes>false<exclude-unlisted-classes>
Anthony
  • 12,177
  • 9
  • 69
  • 105
James
  • 17,965
  • 11
  • 91
  • 146
  • Yes, but no chance. Despite blogs and articles about using JPA in Java SE environment claim, this parameter does not work in SE environment. – koders Mar 19 '12 at 18:51