I was finally able to get a simple example working on Apache Karaf using container-managed Enterprise OSGi JPA.
Pull request:
https://github.com/hibernate/hibernate-orm/pull/465/files
I would really appreciate it if some of you could grab the following fork and try it out in your own environments – feedback is definitely needed:
https://github.com/brmeyer/hibernate-orm/tree/4.2-osgi
A simple test client bundle is available as a reference. Something like this will eventually wind up in the doc examples. Instructions are in the README (rough draft).
https://github.com/brmeyer/HibernateOSGi
There's a few caveats to ORM at this point:
- I have not yet tested a bundle creating and maintaining it's own EntityManagerFactory or SessionFactory. Only container-managed has been used so far.
- Only basic support for persistence units is available. We have not handled the use of OSGi services to register Integrators, etc.
- IMPORTANT: We can currently handle only annotated classes explicitly listed in your persistence unit. There's a few roadblocks preventing us from scanning for mapping files, classes, etc.
- The provided feature.xml files are fairly order-specific. Comments within them (and the proposal wiki) outline the issue.
The proposal wiki is updated with more info and questions:
https://github.com/hibernate/hibernate-orm/wiki/Proposal:-OSGi
We're not comfortable releasing this until the community is able to help confirm the fork. Any help is sincerely appreciated!