[Teneo] Setting an object as 'new' in Teneo/Hibernate [message #80083] |
Tue, 17 April 2007 14:46  |
Eclipse User |
|
|
|
Martin,
In order to support 'undo' for delete operations in my editor I need to be
able to re-save an object that has been deleted from the database. If a
user deletes an object, does a save, the object is deleted fine. However,
if the user then subsequently 'undoes' the delete the 'undo' code re-adds
the object. The problem is that the next save fails with a message that
the row has been deleted or modified by another transaction.
I suspect that the object saved in memory has a signature that makes it
appear as though it exists in the database. I think I need to make the
object appear as a new object so that it can be added to the database as a
new row.
Is this possible.??
Thanks,
Mark.
|
|
|
|
|
|
Re: [Teneo] Setting an object as 'new' in Teneo/Hibernate [message #80234 is a reply to message #80219] |
Wed, 18 April 2007 01:32  |
Eclipse User |
|
|
|
Mark,
You can try:
IdentifierCacheHandler.setId(yourUndeletedObject, null)
(and do session.evict)
gr. Martin
Mark wrote:
> Martin,
>
> How do I set the ID property on my model objects...? The ID is not an
> attribute of my objects.
>
> Mark.
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [Teneo] Setting an object as 'new' in Teneo/Hibernate [message #604817 is a reply to message #80157] |
Tue, 17 April 2007 16:29  |
Eclipse User |
|
|
|
Mark,
You can try to call session.evict(object) and sets its id property to zero (if it is a long) or null
or another sensible not-set value. In this case you need to be sure that the object does not exist
anymore in the db (but it shouldn't because you deleted it).
One thing you have to also consider is that if you undelete an object (save it again after it was
deleted) that also all the objects it refers to have to be undeleted (if they were deleted).
gr. Martin
Mark wrote:
> Martin,
>
> Or, maybe just a way to query to see if the object is still in the
> database, if not I create a copy of the object to store.
>
> Mark.
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [Teneo] Setting an object as 'new' in Teneo/Hibernate [message #604829 is a reply to message #80219] |
Wed, 18 April 2007 01:32  |
Eclipse User |
|
|
|
Mark,
You can try:
IdentifierCacheHandler.setId(yourUndeletedObject, null)
(and do session.evict)
gr. Martin
Mark wrote:
> Martin,
>
> How do I set the ID property on my model objects...? The ID is not an
> attribute of my objects.
>
> Mark.
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.04812 seconds