1

How I can register/unregister new entity class (with annotation or ORM XML) at runtime after EMF is initialized and first EntityManager are created. I know about similar questions, for example: Adding entity classes dynamically at runtime

The difference in the level of dynamism: we use OSGI plugins that can be installed/uninstalled at runtime and can contatais entity classes for own data.

That functionality already implemented using JDO/DataNucleus and works in production about 3 years. But JDO seems to be dead (at Apache too). DataNucleus has relatively small adoption and only one active (and good) developer (that sad because project very interesting in many ways ).

How to do something similar with popular JPA implementations?

Community
  • 1
  • 1
Vladimir Konkov
  • 161
  • 2
  • 9
  • 1
    strange, I see a JDO 3.2 on Apache JDO JIRA, and don't see anything "dead" there (and there is no sign of a JPA 2.2) – Neil Stockton May 13 '15 at 12:37
  • 1
    @NeilStockton thanx for comment and your effort on JDO API. I'am analyzed mailing list and Jira activity... not so match. You and Andy Jefferson try to move JDO forward but your efforts are not enough. Personaly I'am big fun on JDO and want to expand it myself. Unfortunly I'am just **application** architect and absolutly do not have time to develop such a big spec (few patches to DataNucleus not count). – Vladimir Konkov May 13 '15 at 14:53

1 Answers1

0

You can not add classes to an existing EntityManagerFactory. What you should do is create one persistence unit per bundle. So when updating the bundle you get a new EntityManagerFactory as a service. Unfortunately current Apache Aries jpa has a known issue with updating bundles that contain a persistence unit.

I am working on code for an Apache Aries jpa 2.0 release that will be able to handle this.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • I know that **standart** JPA not support that. I'am ask for implementation specific API, like in DataNucleus or OpenJPA (partialy supported). OSGI JPA can't do more than provider does. Actualy, in practice, is simpler to create EMF in bundle and share it with other modules as OSGI service than use OSGI scecified persistence bundles. – Vladimir Konkov May 13 '15 at 14:56