FileDocCategorySizeDatePackage
OptimisticLockException.javaAPI DocGlassfish v2 API8915Tue May 22 16:54:18 BST 2007oracle.toplink.essentials.exceptions

OptimisticLockException

public class OptimisticLockException extends TopLinkException

Purpose: This exception is used when TopLink's optimistic locking feature is used. It will be raised if the object being updated or deleted was changed or deleted from the database since it as last read.

Fields Summary
protected transient ObjectLevelModifyQuery
query
Store the query that raised the optimistic violation.
public static final int
NO_VERSION_NUMBER_WHEN_DELETING
public static final int
OBJECT_CHANGED_SINCE_LAST_READ_WHEN_DELETING
public static final int
NO_VERSION_NUMBER_WHEN_UPDATING
public static final int
OBJECT_CHANGED_SINCE_LAST_READ_WHEN_UPDATING
public static final int
MUST_HAVE_MAPPING_WHEN_IN_OBJECT
public static final int
NEED_TO_MAP_JAVA_SQL_TIMESTAMP
public static final int
UNWRAPPING_OBJECT_DELETED_SINCE_LAST_READ
public static final int
OBJECT_CHANGED_SINCE_LAST_MERGE
Constructors Summary
protected OptimisticLockException(String theMessage)
INTERNAL: TopLink exceptions should only be thrown by TopLink.


                  
       
        super(theMessage);
    
protected OptimisticLockException(String theMessage, ObjectLevelModifyQuery query)
INTERNAL: TopLink exceptions should only be thrown by TopLink.

        super(theMessage);
        this.query = query;
        query.getSession().incrementProfile(SessionProfiler.OptimisticLockException);

    
Methods Summary
public java.lang.ObjectgetObject()
PUBLIC: Return the object for which the problem was detected.

        return getQuery().getObject();
    
public oracle.toplink.essentials.queryframework.ObjectLevelModifyQuerygetQuery()
PUBLIC: Return the query in which the problem was detected.

        return query;
    
public static oracle.toplink.essentials.exceptions.OptimisticLockExceptionmustHaveMappingWhenStoredInObject(java.lang.Class aClass)

        Object[] args = { aClass };

        OptimisticLockException optimisticLockException = new OptimisticLockException(ExceptionMessageGenerator.buildMessage(OptimisticLockException.class, MUST_HAVE_MAPPING_WHEN_IN_OBJECT, args));
        optimisticLockException.setErrorCode(MUST_HAVE_MAPPING_WHEN_IN_OBJECT);
        return optimisticLockException;

    
public static oracle.toplink.essentials.exceptions.OptimisticLockExceptionneedToMapJavaSqlTimestampWhenStoredInObject()

        Object[] args = {  };

        OptimisticLockException optimisticLockException = new OptimisticLockException(ExceptionMessageGenerator.buildMessage(OptimisticLockException.class, NEED_TO_MAP_JAVA_SQL_TIMESTAMP, args));
        optimisticLockException.setErrorCode(NEED_TO_MAP_JAVA_SQL_TIMESTAMP);
        return optimisticLockException;
    
public static oracle.toplink.essentials.exceptions.OptimisticLockExceptionnoVersionNumberWhenDeleting(java.lang.Object object, oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery query)

        Vector key = new Vector();
        if (query.getSession() != null) {
            key = query.getSession().keyFromObject(object);
        }
        Object[] args = { object, object.getClass().getName(), key, CR };

        OptimisticLockException optimisticLockException = new OptimisticLockException(ExceptionMessageGenerator.buildMessage(OptimisticLockException.class, NO_VERSION_NUMBER_WHEN_DELETING, args), query);
        optimisticLockException.setErrorCode(NO_VERSION_NUMBER_WHEN_DELETING);
        return optimisticLockException;
    
public static oracle.toplink.essentials.exceptions.OptimisticLockExceptionnoVersionNumberWhenUpdating(java.lang.Object object, oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery query)

        Vector key = new Vector();
        if (query.getSession() != null) {
            key = query.getSession().keyFromObject(object);
        }
        Object[] args = { object, object.getClass().getName(), key, CR };

        OptimisticLockException optimisticLockException = new OptimisticLockException(ExceptionMessageGenerator.buildMessage(OptimisticLockException.class, NO_VERSION_NUMBER_WHEN_UPDATING, args), query);
        optimisticLockException.setErrorCode(NO_VERSION_NUMBER_WHEN_UPDATING);
        return optimisticLockException;
    
public static oracle.toplink.essentials.exceptions.OptimisticLockExceptionobjectChangedSinceLastMerge(java.lang.Object object)

        
        Object[] args = { object, object.getClass().getName(), CR };

        OptimisticLockException optimisticLockException = new OptimisticLockException(ExceptionMessageGenerator.buildMessage(OptimisticLockException.class, OBJECT_CHANGED_SINCE_LAST_MERGE, args));
        optimisticLockException.setErrorCode(OBJECT_CHANGED_SINCE_LAST_MERGE);
        return optimisticLockException;
    
public static oracle.toplink.essentials.exceptions.OptimisticLockExceptionobjectChangedSinceLastReadWhenDeleting(java.lang.Object object, oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery query)

        Vector key = new Vector();
        if (query.getSession() != null) {
            key = query.getSession().keyFromObject(object);
        }
        Object[] args = { object, object.getClass().getName(), key, CR };

        OptimisticLockException optimisticLockException = new OptimisticLockException(ExceptionMessageGenerator.buildMessage(OptimisticLockException.class, OBJECT_CHANGED_SINCE_LAST_READ_WHEN_DELETING, args), query);
        optimisticLockException.setErrorCode(OBJECT_CHANGED_SINCE_LAST_READ_WHEN_DELETING);
        return optimisticLockException;
    
public static oracle.toplink.essentials.exceptions.OptimisticLockExceptionobjectChangedSinceLastReadWhenUpdating(java.lang.Object object, oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery query)

        Vector key = new Vector();
        if (query.getSession() != null) {
            key = query.getSession().keyFromObject(object);
        }
        Object[] args = { object, object.getClass().getName(), key, CR };

        OptimisticLockException optimisticLockException = new OptimisticLockException(ExceptionMessageGenerator.buildMessage(OptimisticLockException.class, OBJECT_CHANGED_SINCE_LAST_READ_WHEN_UPDATING, args), query);
        optimisticLockException.setErrorCode(OBJECT_CHANGED_SINCE_LAST_READ_WHEN_UPDATING);
        return optimisticLockException;
    
public voidsetQuery(oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery query)
INTERNAL: Set the query in which the problem was detected.

        this.query = query;
    
public static oracle.toplink.essentials.exceptions.OptimisticLockExceptionunwrappingObjectDeletedSinceLastRead(java.util.Vector pkVector, java.lang.String className)

        Object[] args = { pkVector, className };

        OptimisticLockException optimisticLockException = new OptimisticLockException(ExceptionMessageGenerator.buildMessage(OptimisticLockException.class, UNWRAPPING_OBJECT_DELETED_SINCE_LAST_READ, args));
        optimisticLockException.setErrorCode(UNWRAPPING_OBJECT_DELETED_SINCE_LAST_READ);
        return optimisticLockException;