Hibernate.orgCommunity Documentation
Table of Contents
Hibernate targets the OSGi 4.3 spec or later and supports three types of configurations.
For more details about OSGi, the three configurations, hibernate-osgi, extensions points, and caveats, please see the OSGi chapter of the Developer's Guide!
Each configuration has a QuickStart project located within the download bundle (under osgi).
The bundles can be used as-is within Apache Karaf. Feel free to use them as literal
"quick start" bundle templates.
osgi/datasource-h2.xml: Enterprise OSGi JPA usage can include a DataSource installed in the container.
The client bundle's persistence.xml references the DataSource through JNDI. For an
example, see how managed-jpa's persistence.xml calls out the
jta-data-source.
osgi/[project]/features.xml: This is arguably the most important "quick start" material. It defines
a single Karaf feature ("hibernate-test") that demonstrates the necessary 3rd party libraries and
bundle activation ordering.
osgi/[project]/pom.xml: The POM includes typical compile-time dependencies (JPA, OSGi Core,
OSGi Enterprise), as well as OSGi manifest data.
osgi/[project]/src/main/resources/OSGI-INF/blueprint/blueprint.xml:
The Blueprint includes container-managed EntityManager
injection (for managed-jpa), as well as demonstrations showing how to register
your custom implementations of Hibernate extension points.
osgi/[project]/src/main/resources/META-INF/persistence.xml or
osgi/[project]/src/main/resources/hibernate.cfg.xml: Note that the configurations
are no different than typical uses of Hibernate!
osgi/[project]/src/main/java/org/hibernate/osgitest/HibernateUtil.java: Demonstrates how to create an
EntityManagerFactory (JPA) or SessionFactory (Native) using hibernate-osgi's services. Note that in
managed-jpa, this is replaced by DataPointServiceImpl#entityManager, injected by
blueprint.xml (described above).