8. Working with Common Enterprise Libraries

8.1 Working with Hibernate

Importing Hibernate

Hibernate uses CGLIB to dynamically create subclasses of your entity types at runtime. To guarantee that Hibernate and CGLIB can correctly see the types, you must add an Import-Library or Import-Bundle for the Hibernate library or bundle into any bundle that uses Hibernate directly.

Additionally, if other bundles in your application contain types to be persisted by Hibernate, then be sure to specify the import-scope directive of the Import-Bundle header in the bundle that uses Hibernate directly. The import-scope directive tells SpringSource dm Server to implicitly import the bundle into all other bundles that make up the application; this ensures that bundles that indirectly depend on the generated Hibernate classes have access to them, but you do not have to explicitly update their Import-Bundle header, ensuring modularity. For example:

Import-Bundle: com.springsource.org.hibernate;version="[3.2.6.ga,3.2.6.ga]";import-scope:=application

The import-scope directive works only for the bundles in a scoped application (PARs or plans.)