Announcement Announcement Module
Collapse
No announcement yet.
Using openSessionInViewFilter but session is closed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using openSessionInViewFilter but session is closed

    Hello,

    I'm using Spring Hibernate in a Webapplication. To load persistent Objects I use HibernateDaoSupport.

    But in my Business Objects I've 1:Many Relations declared with FetchType.LAZY. So the Collection is not loaded in the dao but somewhere in my presentation Layer. Unfortunately without hibernate session.

    I've googled and found a solutions : the OpenSessionInViewFilter.

    I've defined like this:

    Code:
        <!-- Spring filters -->
        <filter>
            <filter-name>openSessionInViewFilter</filter-name>
            <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    		<init-param>
    			<param-name>sessionFactoryBeanName</param-name>
    			<param-value>org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean</param-value>
    		</init-param>
        </filter>
        <filter-mapping>
            <filter-name>openSessionInViewFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    and it seems to work. The filter is processed for the requests.
    Sadly there is still the error 'no session or session was closed'.

    One relation I use is the Object Log has Many LogEntries. This is defined as Lazy. When I debug my Code I see, that in this line

    Code:
    public Set<LogEntry> getLogEntries() {
            return logEntries;
    }
    logEntries is an instance of PersistentCollection (that's clear) and in the Collection the session the flag closed is set to true.

    Do I have to tell my business objetct which session to use?

    Thanks for your help.

    Mike
Working...
X