Hi gang,
We have some legacy business logic that we are migrating into our current applications domain.
This new domain is made up of a very rich set of POJO domain objects. The legacy system used a custom home grown persistence layer circa the late 90s.
The business logic in question will manipulate the persistent objects within the context of a transaction. However, we do not want any of the changes to the domain objects to be persisted at the end of the transaction. This is simply runtime manipulation of the domain objects that we want to discard prior to the end of a transaction.
Is there a graceful way of doing this without introducing some parallel class hierarchy (ala DTO or some evil cousin)?? We currently catch, log a warning for transient exceptions, and then ignore at the end of the transaction.
A crude pseudo example of what we are trying to accomplish:
1) Transaction is open
2) Persistent domain object A is load into memory
3) Domain logic modifies property B of object A
4) Domain logic creates a transient domain object C and associates it with A
5) Transaction is closed
If we were to open another transaction and find domain object A, we'd like to see it in its original state prior to step 3.
Is there a way to do this without walking our modified graph of objects, dereferencing transient objects and deleting them (or have JVM garbage collect them)? Or is it simply good enough to just ignore transient exceptions?
Regards,
Roll
|