• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Working detached in the service layer

Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i will be happy to your opinions regarding - working detached in the service layer/ business layer.

For my opinion work attached in the servie layeris not a good practice since in this way we bypass the dao layer, which break the encapsulation and resposibility rule of each layer.

I dont love the attach idea, for my option save to the DB need to have single point of responsibility.

Additional point:
Since we begin the transaction in the service layer the objects that will returned from the DAO are in attached mode, so if we want to work detach we have several options:
1. call to evict or clear - not good , because we lose the first level cache advantage.
2. copy them to new objects - not so simple, because they have proxy ...
3. use in solutions like giled.
4. deepl clone by serialize

Do you have more solutions?

a link to similar topic:
Thank you

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic