Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363195 - Support for a persistence unit to encompass multiple bundles
Summary: Support for a persistence unit to encompass multiple bundles
Status: NEW
Alias: None
Product: Gemini.JPA
Classification: RT
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Michael Keith CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-08 11:33 EST by Michael Keith CLA
Modified: 2016-02-17 12:45 EST (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Keith CLA 2011-11-08 11:33:41 EST
Some people have asked for the ability for a persistence unit to include more than just the bundle in which it is defined using the Meta-Persistence header. While this is not supported in the OSGi spec, there might be a way to support it by adding a reference to other bundles from the defining persistence unit bundle.
Comment 1 Cristiano Gaviao CLA 2012-03-08 12:16:05 EST
I think that the scenario of creating bundle fragments having the main persistence bundle as host should be considered too.
Comment 2 Cristiano Gaviao CLA 2012-05-30 16:35:53 EDT
Mike, 
Do you know if the new proposed version 5 of Enterprise Specs brings any changes related to this subject?
Comment 3 Michael Keith CLA 2012-05-30 16:50:58 EDT
There have been no revs to the OSGi JPA spec. I have been too busy to contribute anything there. Maybe in the next round, spec-wise. I haven't looked at this yet in Gemini JPA but there is a chance I might be able to get to it for the 1.1 release. I'll see how much work it is.

-Mike
Comment 4 Thomas Gillet CLA 2012-10-10 04:38:33 EDT
I recently tried to put some entities in a fragment attached to a PU bundle with exclude-unlisted-classes set to false, and it worked perfectly fine: all unlisted entities have been found, including the ones in the fragment.

There are still bugs #335698 and #337425 lying around unanswered, so I wonder, what is the "official" status for fragment support?

Note: works with Gemini 1.0.0.RELEASE / EclipseLink 2.3.1 and above
Comment 5 Michael Keith CLA 2012-10-10 10:21:49 EDT
No, I am afraid it is just accidental. The classes may be getting found after resolve-time when the fragment is attached to the host bundle's class loader. This means there is a possibility that weaving may not work correctly if some other bundle loads the classes before they get woven. 

Was not able to get this feature in 1.1 but will try my best to put it in the next release.
Comment 6 Michael Keith CLA 2013-05-29 16:29:05 EDT
Noticed this method will need to be modified: 
   ServicesUtil.buildServiceProperties
Comment 7 Keith Hertzer CLA 2013-06-27 23:00:42 EDT
We are getting scary log messages at startup just with a single bundle that contains all of our entities that uses enums defined in a different bundle (they are shared with view objects sent to the client). The root cause seems to be that MetadataAsmFactory.buildClassMetadata() is trying to load the shared enum classes via the correct bundle classloader for the parent bundle when that bundle is not actually initialized enough to reference its dependencies. Eventually this causes a ValidationException because it can't tell that the enum implements Serializable. It would be nice to see that fixed at least.
Comment 8 Cristiano Gaviao CLA 2013-07-06 13:03:22 EDT
A nice new documentation showing the EclipseLink support of multiple dbs using Composite Persistence Unit: http://www.eclipse.org/eclipselink/documentation/2.4/solutions/usingmultipledbs.htm