Using same PersistenceUnit across bundles [message #909080] |
Thu, 06 September 2012 09:52  |
Eclipse User |
|
|
|
Currently, I'm separating an application into multiple bundles, because some bundles (core services like user management, ... ) should be used as common bundles across multiple projects.
The project is using Hibernate as persistence framework.
As Virgo can't scan for class annotated with @Entity, I had to add the xml for the persistence unit and the definition of EntityManagerFactory into the app bundle. Now, I have the problem that the EntityManagerFactory isn't available inside this common bundles.
Is there a way that, I can create and use a persistenceunit across bundles or would it be possible to expose the EntityManagerFactory of the app bundle as OSGI service for the core bundles.
Not sure if the second approach of exposing as OSGI service would work from a bundle lifecycle perspective?
Does anyone have a solution if the entities and the daos are distributed across bundles?
Thanks
Patrick
|
|
|
Re: Using same PersistenceUnit across bundles [message #912546 is a reply to message #909080] |
Thu, 13 September 2012 14:48  |
Eclipse User |
|
|
|
Hi Patrick. Is possible. Howover, I strongly recommends that you use Eclipse Gemini JPA and Eclipselink to that.
Eclipse Gemini JPA implements the OSGi JPA Enterprise specification, and hardcodes EclipseLink as backend. You can add Gemini JPA on Virgo.
When you start a bundle with a META-INF/persistence.xml (or other location mapped on MANIFEST.MF), it creates and EMF and publish it on the OSGI registry, using your entity bundle as provider. You can get it where you need. Your domain entities of course, will be acessible too.
Please, see: http://www.eclipse.org/gemini/jpa/
|
|
|
Powered by
FUDForum. Page generated in 0.17688 seconds