Wednesday, 20 April 2016

What are advantages and disadvantages of Detached objects ?


Detached objects
 can be passed across layers 
without using any DTOs.
You can later on re-attach the detached objects to another session.

Advantages of Detached objects
These can be used in long transactions due to user think time.

You can use detached objects from the first transaction to carry data all the way up to the presentation layer, then modify them outside the transaction and re-attach later with a new transaction.


Disadvantages of Detached objects

Detached objects hang around in Hibernate's cache anyway.

Alternative way : It is better to discard objects and re-fetch them on subsequent requests.
This approach is not only more portable but also more efficient.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.