Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.DuplicateIdentityException


                return flags;
            }

            if (tx.isAutoStore() || _fieldMolder.isDependent()) {
                if (value != tx.fetch(fieldClassMolder, curIdentity, null)) {
                    throw new DuplicateIdentityException("");
                }
            }
        } else {
            if (_fieldMolder.isStored() /* && _fieldMolder.isCheckDirty() */) {
                flags.setUpdatePersist(true);
View Full Code Here


                stmt.setObject(count++, ids[i].toSQL(identity.get(i)));
            }

            if (stmt.executeQuery().next()) {
                stmt.close();
                throw new DuplicateIdentityException(Messages.format(
                        "persist.duplicateIdentity", _type, identity));
            }
        } catch (SQLException except2) {
            // Error at the stage indicates it wasn't a duplicate
            // primary key problem. But best if the INSERT error is
View Full Code Here

        // You shouldn't be able to modify an object marked read-only in this
        // transaction.
        Object trackedObject = _tracker.getObjectForOID(engine, oid, false);
        if (identity != null && trackedObject != null) {
            if (trackedObject != object) {
                throw new DuplicateIdentityException(
                        "Object being tracked with the OID created for a dependent "
                        + "object does not match the object to be marked for "
                        + "creation. Fundamental Tracking Error.");
            } else if (_tracker.isDeleted(object)) {
                // Undelete it.
View Full Code Here

            if (_tracker.isDeleted(foundInTransaction)) {
                throw new ObjectDeletedException(Messages.format(
                        "persist.objectDeleted", object.getClass(), identity));
            }
           
            throw new DuplicateIdentityException(
                    "update object which is already in the transaction");
        }

        try {
            _tracker.trackObject(molder, oid, object);
View Full Code Here

        } catch (SQLException except) {
            LOG.fatal(Messages.format("jdo.storeFatal",  _type,  _statement), except);

            Boolean isDupKey = _factory.isDuplicateKeyException(except);
            if (Boolean.TRUE.equals(isDupKey)) {
                throw new DuplicateIdentityException(Messages.format(
                        "persist.duplicateIdentity", _type, internalIdentity), except);
            } else if (Boolean.FALSE.equals(isDupKey)) {
                throw new PersistenceException(Messages.format("persist.nested", except), except);
            }
View Full Code Here

        } catch (SQLException except) {
            LOG.fatal(Messages.format("jdo.storeFatal",  _type,  _statement), except);

            Boolean isDupKey = _factory.isDuplicateKeyException(except);
            if (Boolean.TRUE.equals(isDupKey)) {
                throw new DuplicateIdentityException(Messages.format(
                        "persist.duplicateIdentity", _type, internalIdentity), except);
            } else if (Boolean.FALSE.equals(isDupKey)) {
                throw new PersistenceException(Messages.format("persist.nested", except), except);
            }
View Full Code Here

        } catch (SQLException except) {
            LOG.fatal(Messages.format("jdo.storeFatal",  _type,  _statement), except);

            Boolean isDupKey = _factory.isDuplicateKeyException(except);
            if (Boolean.TRUE.equals(isDupKey)) {
                throw new DuplicateIdentityException(Messages.format(
                        "persist.duplicateIdentity", _type, internalIdentity), except);
            } else if (Boolean.FALSE.equals(isDupKey)) {
                throw new PersistenceException(Messages.format("persist.nested", except), except);
            }
View Full Code Here

        } catch (SQLException except) {
            LOG.fatal(Messages.format("jdo.storeFatal",  _type,  _statement), except);

            Boolean isDupKey = _factory.isDuplicateKeyException(except);
            if (Boolean.TRUE.equals(isDupKey)) {
                throw new DuplicateIdentityException(Messages.format(
                        "persist.duplicateIdentity", _type, internalIdentity), except);
            } else if (Boolean.FALSE.equals(isDupKey)) {
                throw new PersistenceException(Messages.format("persist.nested", except), except);
            }
View Full Code Here

                return internaloid;
                // should catch some other exception if destory is not succeed
            } catch (LockNotGrantedException except) {
                // Someone else is using the object, definite duplicate key
                throw new DuplicateIdentityException(Messages.format(
                    "persist.duplicateIdentity", object.getClass().getName(),
                    internaloid.getIdentity()), except);
            } catch (DuplicateIdentityException except) {
                // we got a write lock and the persistence storage already
                // recorded. Should destory the lock
View Full Code Here

        // add a new entry for this object and use this object as the view
        oid = new OID( engine, molder, depended, identity );
        entry = getObjectEntry( engine, oid );
        if ( identity != null && entry != null ) {
            if ( ! entry.deleted || entry.object != object )
                throw new DuplicateIdentityException( Messages.format( "persist.duplicateIdentity", object.getClass().getName(), identity ) );
            else {
                // If the object was already deleted in this transaction,
                // just undelete it.
                // Remove the entry from a FIFO linked list of deleted entries.
                if ( _deletedList != null ) {
                    ObjectEntry deleted;

                    if ( _deletedList == entry )
                        _deletedList = entry.nextDeleted;
                    else {
                        deleted = _deletedList;
                        while ( deleted.nextDeleted != null && deleted.nextDeleted != entry )
                            deleted = deleted.nextDeleted;
                        if ( deleted.nextDeleted == entry )
                            deleted.nextDeleted = entry.nextDeleted;
                        else
                            throw new PersistenceException( Messages.format("persist.deletedNotFound", identity) );
                    }
                }
            }
        }

        try {
            entry = addObjectEntry( oid, object );
            entry.creating = true;

            if ( _callback != null ) {
                _callback.creating( entry.object, _db );
            } else if ( entry.molder.getCallback() != null ) {
                entry.molder.getCallback().creating( entry.object, _db );
            }

            engine.markCreate( this, oid, object );
        } catch ( LockNotGrantedException lneg ) {
            // yip: do we need LockNotGrantedException, or should we
            // removed them?
            removeObjectEntry( object );
            throw new DuplicateIdentityException("");
        } catch ( PersistenceException pe ) {
            removeObjectEntry( object );
            throw pe;
        } catch ( Exception e ) {
            removeObjectEntry( object );
View Full Code Here

TOP

Related Classes of org.exolab.castor.jdo.DuplicateIdentityException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.