picketlink/picketlink-idm — pull request #2 by mposolda (2012-06-26 09:54:54+00:00)
Title: PLIDM-32

Pull request is adding possibility to start Hibernate transaction lazily.

The patch is adding new configuration option for HibernateIdentityStore "lazyStartOfHibernateTransaction" .

If value of option is false, the behaviour is same like before (Hibernate transaction is started along with start of Picketlink IDM transaction via method HibernateIdentityStoreSessionImpl. startTransaction())

If value of option is "true", Hibernate transaction is started lazily. So it's not started along with Picketlink IDM transaction, but it's started when some Hibernate interaction is really needed. Fortunately HibernateIdentityStore have single access point (method HibernateIdentityStore.getHibernateSession()), which needs to be called everytime some Hibernate operation is called. So Hibernate transaction is started when this method is accessed for particular client for the first time.

I added new thread-local variable to class HibernateIdentityStoreSessionImpl for tracking status of Hibernate transaction. After commit or rollback of Hibernate transaction is thread-local variable always cleared.