Improve hibernate-osgi support in ORM 5

Description

The OSGi documentation lists many caveats present when using hibernate-osgi in ORM 4.2 or 4.3. Many of them are due to architectural constraints within ORM, but several involve 3rd party containers/libraries.

This ticket will track subtasks that attempt to mitigate these caveats in ORM 5.

Technically, multiple persistence units are supported by Enterprise OSGi JPA and unmanaged Hibernate JPA use. However, we cannot currently support this in OSGi. In Hibernate 4, only one instance of the OSGi-specific ClassLoader is used per Hibernate bundle, mainly due to heavy use of static TCCL utilities. We hope to support one OSGi ClassLoader per persistence unit in Hibernate 5.

Some containers (ex: Aries) always return true for PersistenceUnitInfo#excludeUnlistedClasses, even if your persistence.xml explicitly has exclude-unlisted-classes set to false. They claim it's to protect JPA providers from having to implement scanning ("we handle it for you"), even though we still want to support it in many cases. The work around is to set hibernate.archive.autodetection to, for example, hbm,class. This tells hibernate to ignore the excludeUnlistedClasses value and scan for *.hbm.xml and entities regardless.

Scanning does not currently support annotated packages on package-info.java.

The environment should be considered STATIC. Hibernate currently does not support the ability to dynamically add and remove client bundles during runtime. Doing so is typically catastrophic. We hope to better support at least partially-dynamic environments in Hibernate 5.

In addition:

  • Investigate whether or not Aries (and other containers) support scanning explicitly-listed jars

follows up on

Activity

Show:

Christian Beikov May 5, 2022 at 10:08 AM

OSGi support was removed in 6.0

De Gaia November 4, 2013 at 4:39 PM

Hi Brett! After many conversation with Peter i was able to get access to his latest tutorial concerning JPA, with Hibernate and OSGi. You can have access to the link to get some inspiration and maybe ask specific questions to him. He told me also that he will adapt the example with the latest version of Hibernate. Since this example is with Hibernate 3.18.

Anyway it would be very good to have your feedback about his work.

Thank you

https://github.com/osgi/osgi.enroute.blog/tree/master

Out of Date

Details

Assignee

Reporter

Priority

Created September 12, 2013 at 6:58 PM
Updated May 5, 2022 at 10:08 AM
Resolved May 5, 2022 at 10:08 AM