Hibernate/Spring: Session still closed before retrieval of child collection even with @Transactional on Service method

后端 未结 2 1842
梦如初夏
梦如初夏 2021-01-25 12:55

Hello Spring/Hibernate Gurus!

in a time like this i would like you to be my best friends.I am working on a project using hibernate 3.6.1.Final JPA implementation using s

2条回答
  •  日久生厌
    2021-01-25 13:52

    Does this happen when rendering the view? If it is the case you might want to consider using Spring's OpenSessionInViewFilter. This will bind the Session to the thread for the entire processing of the request. If using JPA you can use OpenEntityManagerInViewFilter.

    In your web.xml:

    
        OpenSessionInViewFilter
        org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
        
            sessionFactoryBeanName
            sessionFactory
        
    
    
    
        OpenSessionInViewFilter
        /*
    
    

提交回复
热议问题