• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - using 'services'; is this consider a good design?

 
Adrian Burlington
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Adrian Burlington
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic