Re: Aw: Re: Rolling back twice
Posted by
Alan Knight-2 on
May 11, 2011; 6:33pm
URL: https://forum.world.st/Rolling-back-twice-tp3514457p3515446.html
Yes, I think that's exactly right. I'll see about adding that to the
current versions.
Alan,
that's exactly what I was looking for: rollbackAndConitnue.
Looking at #commitUnitOfWorkAndContinue, the implementation
would be straghtforward:
rollbackUnitOfWorkAndContinue
|
registeredObjects |
currentUnitOfWork isNil ifTrue: [^self error: 'Not in unit of
work'].
registeredObjects := currentUnitOfWork registeredObjects.
"
currentUnitOfWork deletedObjects do: [:each |
registeredObjects remove: each]."
self
rollbackUnitOfWork.
self
beginUnitOfWork.
self
registerAll: registeredObjects.
This would surely be safe for changed objects and I guess also
for to-be-deleted objects that simply won't be deleted now that
we rollback.
But what to do with objects that were registered as new? They
should be removed from the collection for re-registration,
shouldn't they?
So do you think replacing the line I commented out above with
the following would be safe?
currentUnitOfWork
newObjects do: [:each | registeredObjects remove: each].
Or am I on the wrong track?
Do you think adding rollbackAndContinue to an official GLORP
version makes sense?
Joachim
There is an API saveAndContinue on GlorpSession. It sounds like
what you want is a rollbackAndContinue, implemented the same
way. I think just removing the line about deleted objects and
changing the commit to a rollback would be enough.
--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To post to this group, send email to
[hidden email].
To unsubscribe from this group, send email to
[hidden email].
For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.