Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

Hibernate

Posted by Pankil Patel on February 18, 2010

1) Keep Open Session for Hibernate Object in View Mode
During lazy loading of hibernate object, your base object should be connected with the hibernate session.

To keep Session connected with your hibernate object add bellow Filter and it’s mapping into your application’s web.xml file

<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>

Advertisements

2 Responses to “Hibernate”

  1. sachin said

    Hi pankil,

    Whe I put the above code in web.xml and try to run the web application I got below error:

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘sessionFactory’ is defined

    session-factory I have defined in dispatcher-servelet.xml file.

    How to make sessionfactory available to filter?

    Cheers,
    sachin.

    • Hi Sachin,

      You error is not related to this filter, its related to your “sessionFactory” bean defined in your configration file.

      Its either “sessionFactory” configration issue, or due to some other fault in your configration file “sessionFactory” is not able to proceed to initialized.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

»
 
%d bloggers like this: