001
014
015 package com.liferay.portal.spring.hibernate;
016
017 import org.springframework.orm.hibernate3.HibernateTransactionManager;
018 import org.springframework.orm.hibernate3.SessionHolder;
019
020
023 public class LastSessionRecorderHibernateTransactionManager
024 extends HibernateTransactionManager {
025
026 @Override
027 protected Object doGetTransaction() {
028 SessionHolder sessionHolder =
029 SpringHibernateThreadLocalUtil.getResource(getSessionFactory());
030
031 if (sessionHolder != null) {
032 LastSessionRecorderUtil.setLastSession(sessionHolder.getSession());
033 }
034
035 return super.doGetTransaction();
036 }
037
038 static {
039 try {
040 Class.forName(SpringHibernateThreadLocalUtil.class.getName());
041 }
042 catch (ClassNotFoundException cnfe) {
043 throw new ExceptionInInitializerError(cnfe);
044 }
045 }
046
047 }