Gemini JPA - Dynamic Entities [message #1234645] |
Wed, 22 January 2014 13:16  |
Eclipse User |
|
|
|
Hi Folks.
I'm using Gemini JPA with Eclipse Virgo, and for now, everything is working nice. I have a domain bundle, that only holds my entities. I have a default persistence.xml file, with basic properties.
The JDBC DataSource is not managed by the domain bundle, because i'm using the EntityManagerFactoryBuilder Service:
<osgi:reference id="entityManagerFactoryBuilder" interface="org.osgi.service.jpa.EntityManagerFactoryBuilder"
filter="(osgi.unit.name=MyPUName)" cardinality="1..1" />
It works nice. But, as my application is very modular, some modules may carry their own entities, and I dont want to deploy a new Persistence Unit, becase I want to integrate the entities. It will be great if exists a way to "register" the new entities, or if we can deploy "domain extension entities" as fragments to the domain bundle. I don't need to unregister the entity later, only register new ones.
Appreciate any help!
Thanks
|
|
|
|
Re: Gemini JPA - Dynamic Entities [message #1237263 is a reply to message #1237220] |
Wed, 29 January 2014 09:07   |
Eclipse User |
|
|
|
JPA is a specification that does not care about the dynamics of an OSGi environment. Simply using JPA in an OSGi environment doesn't make it more dynamic. Having only a part of the entities available when the persisitence unit is discovered is nothing that a JPA framework like EclipseLink or Hibernate could handle. Same goes for uninstalling bundles containing entities. In both cases the JPA framework would have to update its internal meta model at runtime. Additionally there happens a lot of Java classloading and byte code weaving in these frameworks that make spreading entities over many bundles much more complicated.
I think thats why the OSGi JPA spec specifies that there has to be one persisitence bundle that contains all the entities.
@Eduardo Maybe you could create a persistence bundle that contains all entities at compile time and then deploy this persistence bundle.
[Updated on: Wed, 29 January 2014 09:09] by Moderator Report message to a moderator
|
|
|
Re: Gemini JPA - Dynamic Entities [message #1238071 is a reply to message #1237263] |
Fri, 31 January 2014 10:17  |
Eclipse User |
|
|
|
Hi folks!
Thanks by your answers!
Thomas, I will read the docs that you mention. Maybe we can build a entity registration service, to handle this. 
Sebastian. You pass a good starting point too. I know that all the entities are resolved directly on the domain bundle. Because that, I think that maybe fragments can be used to extend the domain bundle, as it must be avaliable at the same time as the domain bundle (not as an OSGi rule, but you can force this in your structure) and the classpath will be merged, so, a classpath scan can access the new classes without the classloader issues (i think) .
The approach that you mention (merge all classes into a single bundle before deploy) is a way, but it will be a chalenge, because the idea is offer a plugin API that can have a build life cicle outside the main application. I can try to get some hook on the deploy, and scan bundles with a special metatag, and merge it. I will check with with Virgo guys! Maybe they can help me .
Again, thanks by your help!!
|
|
|
Powered by
FUDForum. Page generated in 0.05982 seconds