FileDocCategorySizeDatePackage
ForUpdateOfClause.javaAPI DocGlassfish v2 API4816Tue May 22 16:54:32 BST 2007oracle.toplink.essentials.internal.expressions

ForUpdateOfClause

public class ForUpdateOfClause extends ForUpdateClause
Purpose:Represents The FOR UPDATE OF fine-grained pessimistically locking clause.
author
Stephen McRitchie
since
Oracle Toplink 10g AS

Fields Summary
protected Vector
lockedExpressions
Constructors Summary
public ForUpdateOfClause()

    
Methods Summary
public voidaddLockedExpression(oracle.toplink.essentials.internal.expressions.ObjectExpression expression)

        getLockedExpressions().addElement(expression);
    
public java.util.VectorgetLockedExpressions()

        if (lockedExpressions == null) {
            lockedExpressions = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance();
        }
        return lockedExpressions;
    
public booleanisForUpdateOfClause()

        return true;
    
public booleanisReferenceClassLocked()

        if (lockedExpressions == null) {
            return false;
        }

        // Normally the expressionBuilder is stored first but not necessarily 
        // when a child ForUpdateOfClause is built for a nested query, or if a 
        //user made this clause.
        for (int i = 0; i < lockedExpressions.size(); i++) {
            if (((Expression)lockedExpressions.elementAt(i)).isExpressionBuilder()) {
                return true;
            }
        }
        return false;
    
public voidprintSQL(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer, oracle.toplink.essentials.internal.expressions.SQLSelectStatement statement)
INTERNAL: Prints the as of clause for an expression inside of the FROM clause.

        // assert(lockedExpressions != null && lockedExpressions.size() > 0);
        // assert(	getLockMode() == ObjectBuildingQuery.LOCK || 
        //			getLockMode() == ObjectBuildingQuery.LOCK_NOWAIT);
        ExpressionBuilder clonedBuilder = statement.getBuilder();

        printer.printString(printer.getSession().getPlatform().getSelectForUpdateOfString());

        printer.setIsFirstElementPrinted(false);
        for (Enumeration enumtr = getLockedExpressions().elements(); enumtr.hasMoreElements();) {
            ObjectExpression next = (ObjectExpression)enumtr.nextElement();

            // Neccessary as this was determined in query framework.
            next = (ObjectExpression)next.rebuildOn(clonedBuilder);
            next.writeForUpdateOfFields(printer, statement);
        }
        if (lockMode == ObjectBuildingQuery.LOCK_NOWAIT) {
            printer.printString(printer.getSession().getPlatform().getSelectForUpdateNoWaitString());
        }
    
public voidsetLockMode(short lockMode)

        this.lockMode = lockMode;
    
public voidsetLockedExpressions(java.util.Vector lockedExpressions)

        this.lockedExpressions = lockedExpressions;