Thanks everyone for the responses . But to be a bit more specific how does 
hibernate deal with entity reloading ie ones a version of entity is registered 
and the session factory created how does it work when the entity class is 
modified/refreshed as part of a bundle update ?.

I definitely need to check on the latest version to see if altering the session 
factory or a corresponding unregister method like is present.

Thanks
Jens

From: Christian Schneider [mailto:[email protected]] On Behalf Of 
Christian Schneider
Sent: 07 May 2015 01:32
To: [email protected]
Subject: Re: Hibernate OSGi Integration

Hibernate works quite smothly in karaf 3. In my tutorial 
http://www.liquid-reality.de/x/C4DK I describe a complete example.
As you can see it works almost without any quirks. The only special setup was 
to declare some special Import-Package statements in the model bundle to make 
load time weaving work.
The data sources can now be declared using just a config file in etc using 
pax-jdbc including XA transaction wrapping and production level pooling.

Christian
Am 06.05.2015 um 15:48 schrieb Andrew Phillips:
I have used Hibernate successfully (including Hibernate Search) in an OSGI / 
Karaf environment.

If you have some specific questions, i’d be more than happy to help.

I have found that Hibernate has some examples of OSGI implementation using 
Karaf.   Karaf has the “features” ability to add all the dependencies, in the 
right order, for the file you are using.  In fact, i think Karaf now has a 
built in “hibernate” feature, although i built my own features to fine tweak 
the dependencies and usage.   Once Hibernate is available as a service (and the 
configuration depends on either you are using native hibernate session factory 
or JPA entity manger), you can have your annotated entities classes in a 
different OSGI bundle and use them as any other bundle as you describe.

The down side of the current OSGI hibernate setup (which is really just a “make 
it work” set up, and newer versions of Hibernate are promised to make it more 
OSGI like), is that you need to use the Hibernate.cfg or .xml file to configure 
that data source and register the entity classes.

The examples described in 
http://docs.jboss.org/hibernate/orm/5.0/devguide/en-US/html/ch17.html do a good 
job getting you started.

You can have your entities in a separate bundle if you wish or in the same 
bundle with your session factory singleton.


On May 5, 2015, at 10:43 PM, Jens J Parappallil 
<[email protected]<mailto:[email protected]>> wrote:

Hi,

I am planning to integrate hibernate in my project, I have many bundles which 
has entity classes present ( and exported ) . I am planning to have a core 
bundle which holds the hibernate session factory etc and manages the 
persistence stuff.

I am thinking how this works out in an OSGi environment where the bundles ( 
having entity classes ) can come and go. The hibernate session factory is a 
singleton , to be created ones and used. Can it wok with annotated entities 
coming and going ?

This is more of a hibernate question , but any of you guys have envisioned such 
a usage pattern and made it work ?

Thanks
Jens


DISCLAIMER: "The information in this e-mail and any attachment is intended only 
for the person to whom it is addressed and may contain confidential and/or 
privileged material. If you have received this e-mail in error, kindly contact 
the sender and destroy all copies of the original communication. IBS makes no 
warranty, express or implied, nor guarantees the accuracy, adequacy or 
completeness of the information contained in this email or any attachment and 
is not liable for any errors, defects, omissions, viruses or for resultant loss 
or damage, if any, direct or indirect."




DISCLAIMER: "The information in this e-mail and any attachment is intended only 
for the person to whom it is addressed and may contain confidential and/or 
privileged material. If you have received this e-mail in error, kindly contact 
the sender and destroy all copies of the original communication. IBS makes no 
warranty, express or implied, nor guarantees the accuracy, adequacy or 
completeness of the information contained in this email or any attachment and 
is not liable for any errors, defects, omissions, viruses or for resultant loss 
or damage, if any, direct or indirect."

Reply via email to