Menu

Seperate design and impl. using hibernate

ctang
2003-07-11
2003-07-14
  • ctang

    ctang - 2003-07-11

    I am studying the code of security-example and find the the UserDAO depends on Hibernate Session object.  UserDAO is interface which should not depend on implemention related classes.  Is there a better way? 

    I put all the hibernate session management (opening a new or reconnect) in implementation class.  I don't like this approach eigher because the implementation codes assumes the long (short) transaction already.  The client loses control when to or not to reconnect.  The good part is seperation of design and implementation.

    Thanks!

    ct

     
    • Matt Raible

      Matt Raible - 2003-07-11

      My explanation for doing it this way can be found at:

      http://raibledesigns.com/page/rd?anchor=hibernate_open_session_in_view

      HTH,

      Matt

       
    • ctang

      ctang - 2003-07-14

      Hi Matt,

      Thanks for your reply.  I just start to look at spring frame work (http://www.springframework.org), it has implemented wrapper for hibernate.  It looks good from my reading.  What do you think of that?

      Thanks!

      ct

       
      • Matt Raible

        Matt Raible - 2003-07-14

        I have heard of the spring framework, but I'm a little hesitant about introducing a new framework into this app at this point.  My main reason is I don't want to sit down and learn it right now. ;-)

        Also, it looks like it eliminates the open-session-in-view pattern and opens/closes each session at a method level.

         

Log in to post a comment.