I have extended sessionfilter which sets the flush mode to auto in getSession() method and in close session method closes if session is not closed it calls flush and finally closes , I also use Spring @Transaction annotation, First I am confused with the hibernate property
hibernate.current_session_context_class what should be the value of this and how this will effect my setup ,
and why am i doting this
and this ?Code:<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
Code:<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean>
and finally how will this help me ?
Code:<prop key="hibernate.connection.release_mode">auto</prop>Code:public class HibernateFilter extends OpenSessionInViewFilter { @Override public void setSingleSession(boolean singleSession) { // TODO Auto-generated method stub super.setSingleSession(false); } @Override protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException { Session session = SessionFactoryUtils.getSession(sessionFactory, true); // set the FlushMode to auto in order to save objects. session.setFlushMode(FlushMode.AUTO); return session; } @Override protected void closeSession(Session session, SessionFactory sessionFactory) { try { if (session != null && session.isOpen() && session.isConnected()) { try { session.flush(); } catch (HibernateException e) { throw new CleanupFailureDataAccessException( "Failed to flush session before close: " + e.getMessage(), e); } catch (Exception e) { } } } finally { super.closeSession(session, sessionFactory); } } }


Reply With Quote