Announcement Announcement Module
Collapse
No announcement yet.
hibernate configration with Open view session filter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • hibernate configration with Open view session filter

    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
    Code:
    <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
    and this ?
    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);
    		}
    	}
    }

  • #2
    Just wondering why? Flushing occurs automatically because it is handled from withing the transaction which is started with spring.

    the 'hibernate.current_session_context_class' shouldn't be set only if you use JTA and judging from your configuration you don't. The same goes for the 'hibernate.transaction.factory_class' key it shouldn't be set either.

    I still don't get what you are trying to achieve with your own OSIVF....

    Comment

    Working...
    X