• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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!
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic