You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Markus Reich <ma...@markusreich.at> on 2013/09/20 20:41:29 UTC

Unchanged version of data object

Hi,

is there a way to get a unchanged (original version) of a CayenneDataObject
that is changed and not commited? Or does a rollback reload data from DB?

regards
Markus

Re: Unchanged version of data object

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Sep 20, 2013, at 9:41 PM, Markus Reich <ma...@markusreich.at> wrote:

> Hi,
> 
> is there a way to get a unchanged (original version) of a CayenneDataObject
> that is changed and not commited? Or does a rollback reload data from DB?
> 
> regards
> Markus

Rollback reverts the changes without a DB trip. So a rollback will give you an unchanged version (and the uncommitted changes will be gone forever). 

If you want to keep the changes, but still have a version of the same DataObject that represents the DB state, you might create a second parallel ObjectContext and look up that object there. There are also ways to pick at cached snapshot of the changed object.

HTH,
Andrus