| Author |
Hibernate - using 'services'; is this consider a good design?
|
Adrian Burlington
Ranch Hand
Joined: Jun 16, 2009
Posts: 75
|
|
Hi there,
I'd like to know what is the best practice to use hibernate; I would like to know if what I'm doing make sense.
I have couple of services:
SecurityService
HRService
AccountService
every service has it's own purpose; for example HRService can add new employee, save, remove etc...
the HRService looks like this
Q: base on the design above - is this a good why to utilize hibernate? is there a better way?
should I close the connection at the end? should every method start with line1 and line2; should I create save method for every class.
Thanks for any input.
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
I typically make a J2EE Application Service part of all of my designs.
App flow goes from a front controller to a managed bean to a business delegate to an application service to a DAO to the database.
Keep the Hibernate stuff in a DAO, and have the service invoke the DAOs. No transaction management in the DAO, but in the service class instead.
That's a darn good design.
-Cameron McKenzie
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
Adrian Burlington
Ranch Hand
Joined: Jun 16, 2009
Posts: 75
|
|
Keep the Hibernate stuff in a DAO, and have the service invoke the DAOs. No transaction management in the DAO, but in the service class instead.
Thank you Cameron for your tip.
I wonder if you could elaborate more about what you said so I can use your design.
Thanks again!
|
 |
 |
|
|
subject: Hibernate - using 'services'; is this consider a good design?
|
|
|