Instead of having database actions scattered in four (osgi) bundles, all doing there slightly different things. I want to create a (simple) OSGi bundle that is responsible for a
(If you are using Hibernate Annotations)
Save all the Entities class loaders when the Hibernate bundle is informed about an annotated class.
Then do something like this before building your SessionFactory.
ClassLoad cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(yourClassLoader);
factory = cfg.buildSessionFactory();
}finally {
Thread.currentThread().setContextClassLoader(cl); // restore the original class loader
}