Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Gemini JPA - Dynamic Entities(Is possible to extend the original domain bundle?)
Gemini JPA - Dynamic Entities [message #1234645] Wed, 22 January 2014 13:16 Go to next message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 118
Registered: January 2012
Senior Member
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 #1237220 is a reply to message #1234645] Wed, 29 January 2014 06:42 Go to previous messageGo to next message
Thomas Wilhelm is currently offline Thomas WilhelmFriend
Messages: 28
Registered: September 2013
Junior Member
Hey Eduardo,

did you found a solution? I (and some other people here) have exactly the same problem, but the only answer you will find is

"use Dynamic JPA" (http://wiki.eclipse.org/EclipseLink/Examples/JPA/Dynamic)

or MetadataSource (http://wiki.eclipse.org/EclipseLink/Examples/JPA/MetadataSource).

I looked at both and couldn´t figure out how this can be used to solve my problem. If you find out, please post your solution Wink

Greetz,
Thomas
Re: Gemini JPA - Dynamic Entities [message #1237263 is a reply to message #1237220] Wed, 29 January 2014 09:07 Go to previous messageGo to next message
Sebastian Lorenz is currently offline Sebastian LorenzFriend
Messages: 42
Registered: November 2010
Member
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]

Report message to a moderator

Re: Gemini JPA - Dynamic Entities [message #1238071 is a reply to message #1237263] Fri, 31 January 2014 10:17 Go to previous message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 118
Registered: January 2012
Senior Member
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. Smile

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) Smile.

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 Smile.

Again, thanks by your help!!
Previous Topic:OSGI to access weblogic JNDI
Next Topic:DBAccess for MySQL Installation Failed
Goto Forum:
  


Current Time: Tue Dec 23 00:09:07 GMT 2014

Powered by FUDForum. Page generated in 0.01931 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software