1 21 package oracle.toplink.essentials.internal.expressions; 23 24 import java.util.*; 25 import oracle.toplink.essentials.expressions.*; 26 import oracle.toplink.essentials.queryframework.ObjectBuildingQuery; 27 28 34 public class ForUpdateOfClause extends ForUpdateClause { 35 protected Vector lockedExpressions; 36 37 public ForUpdateOfClause() { 38 } 39 40 public void addLockedExpression(ObjectExpression expression) { 41 getLockedExpressions().addElement(expression); 42 } 43 44 public Vector getLockedExpressions() { 45 if (lockedExpressions == null) { 46 lockedExpressions = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 47 } 48 return lockedExpressions; 49 } 50 51 public boolean isForUpdateOfClause() { 52 return true; 53 } 54 55 public boolean isReferenceClassLocked() { 56 if (lockedExpressions == null) { 57 return false; 58 } 59 60 for (int i = 0; i < lockedExpressions.size(); i++) { 64 if (((Expression)lockedExpressions.elementAt(i)).isExpressionBuilder()) { 65 return true; 66 } 67 } 68 return false; 69 } 70 71 public void setLockedExpressions(Vector lockedExpressions) { 72 this.lockedExpressions = lockedExpressions; 73 } 74 75 public void setLockMode(short lockMode) { 76 this.lockMode = lockMode; 77 } 78 79 83 public void printSQL(ExpressionSQLPrinter printer, SQLSelectStatement statement) { 84 ExpressionBuilder clonedBuilder = statement.getBuilder(); 88 89 printer.printString(printer.getSession().getPlatform().getSelectForUpdateOfString()); 90 91 printer.setIsFirstElementPrinted(false); 92 for (Enumeration enumtr = getLockedExpressions().elements(); enumtr.hasMoreElements();) { 93 ObjectExpression next = (ObjectExpression)enumtr.nextElement(); 94 95 next = (ObjectExpression)next.rebuildOn(clonedBuilder); 97 next.writeForUpdateOfFields(printer, statement); 98 } 99 if (lockMode == ObjectBuildingQuery.LOCK_NOWAIT) { 100 printer.printString(printer.getSession().getPlatform().getSelectForUpdateNoWaitString()); 101 } 102 } 103 } 104 | Popular Tags |