Announcement Announcement Module
Collapse
No announcement yet.
Question about HibenateDaoSupport getSession() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about HibenateDaoSupport getSession()

    If I call getSession() to use query by criteria, do I then have to explicitly close the session?

  • #2
    If you are letting Spring handle your session for you, then no, never close the session.

    It would also be better to use the callback (doInHibernate) methods which provide you with a session.

    How are you configuring your sessionFactory?

    Comment


    • #3
      Thanks for replying. I have my sessionFactory configured in the applicationContext using org.springframework.orm.hibernate3.LocalSessionFac toryBean

      Comment


      • #4
        Then no, don't close the session explictly.

        Comment


        • #5
          How can we access the spring 's existing transactional session from our DAO's?

          Comment


          • #6
            Use hibernate interceptor or a hibernate template and read the reference documentation.
            The current session (transactional or not) will be exposed to your code.
            Review the documentation and the samples as they cover all this cases.

            Comment

            Working...
            X