• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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

 
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.
 
author and cow tipper
Posts: 5000
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!
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!