Title: Issue with 2 updates on a record in the same transaction...

Is the object to be updated the same instance?

 

If not, it shouldn’t be done. One instance per identity of the same type rule can be broken. Otherwise, it is causing some undeterminable behavior. Because Castor is not designed to deal with that.

 

Otherwise, try to setAutoStore( true ). That mode is more forgiving on multiple update.

 

 

Thomas

 

 

 

-----Original Message-----
>From: May, Darrell [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, August 15, 2001 7:54 AM
>To: [EMAIL PROTECTED]
>Subject: [castor-dev] Issue with 2 updates on a record in the same transaction...
>
>
We are using Castor with Jrun and have run into an issue with updating the same record more than once inside the same transaction.
>
The exception is DuplicateIdentityException: update object which is already in the transaction.
>
I have found that it's thrown on line 904 in TransactionContext.java, here's a snip of code:
>
        if ( entry != null ) {
>
            if ( entry.deleted )
>
                throw new ObjectDeletedException( Messages.format("persist.objectDeleted", object.getClass(), identity ) );
>
            else
>
                throw new DuplicateIdentityException( "update object which is already in the transaction" );
>
        }
>
We have the need to allow updates to the same record more than once, with the behavior that the last update is the one that is commited.
>
We have modified the code temporarily to:
>
        if ( entry != null ) {
>
            if ( entry.deleted )
>
                throw new ObjectDeletedException( Messages.format("persist.objectDeleted", object.getClass(), identity ) );
>
            //else
>
                //throw new DuplicateIdentityException( "update object which is already in the transaction" );
>
        }
>
And this seems to work perfectly for us.  Does anyone see any side affects from this?
>
It would be nice to engineer this as to set this behavior on and off. 
>
Darrell May
>
Software Architect
>
Cyberplex
>
Waterloo Development Center
>
[EMAIL PROTECTED]
>
http://www.cyberplex.com
>

Reply via email to