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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
My explanation for doing it this way can be found at:
http://raibledesigns.com/page/rd?anchor=hibernate_open_session_in_view
HTH,
Matt
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
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.