Kavathekar, Sunit wrote:

I have a working castor intall which I can use to read and insert objects. When I try 
any updates to any object at all, I get an ObjectModifiedException as follows:

6871 [main] ERROR com.amazon.invhealth.disposition.dispsitionchannels.marketplace.tests.TestMarketplaceDataManipulator - Persistence Exception in executeDispositionDecision from JDO layer
org.exolab.castor.jdo.ObjectModifiedException: Transaction aborted: Object of type com.amazon.invhealth.disposition.dataentities.RemovalCandidate with identity 1,335,206,261 has been modified by a concurrent transaction (cache entry is different from database row)
at org.exolab.castor.jdo.engine.SQLEngine.store(SQLEngine.java:880)
at org.exolab.castor.persist.ClassMolder.store(ClassMolder.java:1609)
at org.exolab.castor.persist.LockEngine.store(LockEngine.java:750)
at org.exolab.castor.persist.TransactionContext.prepare(TransactionContext.java:1540)
at org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:512)
at



The code is simple enough - load an object and modify it then commit.

                try {

            // Define the JDO object
            db = MarketplaceChannelDataAccessor._db;
            // Begin a transaction
            db.begin();
            // Do something
            RemovalCandidate rc = (RemovalCandidate)db.load(RemovalCandidate.class,new 
Long(1335206261L));
            rc.setQuantity(0);
            rc.setOriginalBinItemQuantity(0);
            rc.setRefundAmount(0);
            rc.setRemovalReasonNotes("Test for disposition service");

            db.commit();

        } catch (PersistenceException e) {
            Logger.getLogger(this.getClass()).error("Persistence Exception in 
executeDispositionDecision from JDO layer", e);
            try {
                //dbConn.rollback();
                db.rollback();
            } catch (PersistenceException eSQL) {
                Logger.getLogger(this.getClass()).error("Persistence Exception during txn 
rollback from JDO layer", eSQL);
            }
        }

Sunit,

It looks to me like the client code posted above is OK. The only question I have is the comment that states 'Do something'. Have you removed some code there and replaced it with that comment? Also please post the relevant portion of the mapping descriptor for classes involved above.

Bruce
--
perl -e 'print unpack("u30","<0G)[EMAIL PROTECTED]&5R\\"F9E<G)E=\\$\\!F<FEI+F-O;0\\`\\`");'


The Castor Project
http://www.castor.org/

Apache Geronimo
http://incubator.apache.org/projects/geronimo.html



----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user

Reply via email to