• Post Reply Bookmark Topic Watch Topic
  • New Topic

Working detached in the service layer  RSS feed

avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • 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

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!