Results 1 to 3 of 3

Thread: Best practice using OpenSessionInView

  1. #1
    Join Date
    May 2006
    Location
    Switzerland
    Posts
    24

    Default Best practice using OpenSessionInView

    Hi,

    I would like to know wich is the best practice to enable OpenSessionInView and using getSessionFactory.getSession() inside a Dao implementation or is it better to use getHibernateTemplate().updateOrSave

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Neither. Don't extend HibernateDaoSupport, simply inject the SessionFactory into your dao's. Then use the current session mechanism to retrieve the session.

    Code:
    public class MyDaoImpl implements MyDao {
    
      private SessionFactory sf;
    
      public void save(Object o) {
        sf.getCurrentSession().save(o);
      }
    
    }
    Which about summarizes it.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    May 2006
    Location
    Switzerland
    Posts
    24

    Default

    Well thanks for your response !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •