I'm trying to figure out if it's possible to have a separate SessionFactory for each of the bundles that use Hibernate for persistence. I've seen several places that talk about having a single SessionFactory that get dynamically reconfigured when new bundles are added that have classes that should be persisted. But I haven't seen anything about having something like a SessionFactory for each bundle. Obviously a couple of things I'm worried about are:
1) How will Hibernate load classes from the other bundles that use it? I thought of making sure that the thread classloader used when the Configuration object is created and the SessionFactory created is the bundle classloader, but is that enough?
2) How much static data is used by Hibernate? I know that at least the session caches are associated with Session objects, but what about the L2 cache? Is it associated with the SessionFactory or is it global? What about other configuration data, like I noticed the Environment object seems to be nothing but static state for configuration data.
I'm sure others will follow from answers to the above and I'm sure there are others that I'm not thinking of, but that's all I can think of at midnight on a Saturday. :)
Thanks,
Rich
|