Detached objects can be passed across layers upto the presentation layer without having to use any DTOs.
You can re-attach the detached objects to another session.
Pros
- Use in long transactions
When long transactions are required due to user think-time, it is the best practice to break the long transaction up into two or more transactions.
Use case
- Use detached objects from the first transaction to carry data all the way up to the presentation layer.
- These detached objects get modified outside a transaction
- Later, re-attach to a new transaction via another session
Cons
- Quite cumbersome to use
Instead, re-fetch them on subsequent requests - More efficient - The objects hang around in Hibernate' s cache anyway.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.