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.
{quote} 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.
Scanning is supported to find non-explicitly listed entities and mappings. However, they MUST be in the same bundle as your persistence unit (fairly typical anyway). Our OSGi ClassLoader only considers the "requesting bundle" (hence the requirement on using services to create EMF/SF), rather than attempting to scan all available bundles. This is primarily for versioning considerations, collision protections, etc.
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.
Currently, Hibernate OSGi is primarily tested using Apache Karaf and Apache Aries JPA. Additional testing is needed with Equinox, Gemini, and other container providers.
Hibernate ORM has many dependencies that do not currently provide OSGi manifests. The QuickStart tutorials make heavy use of 3rd party bundles (SpringSource, ServiceMix) or the wrap:... operator.
As previously mentioned, bundle activation is currently order specific. See the QuickStart tutorials' features.xml for example sequences.
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. No Enterprise OSGi JPA container currently supports JPA 2.1 (the spec is not yet released). For testing, the managed-jpa example makes use of Brett's fork of Aries. To work with Hibernate 4.3, clone the fork and build Aries JPA. {quote}
In addition: * Investigate whether or not Aries (and other containers) support scanning explicitly-listed jars
|