• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic