1 21 package oracle.toplink.essentials.internal.expressions; 23 24 import java.io.*; 25 import oracle.toplink.essentials.queryframework.ObjectBuildingQuery; 26 27 32 public class ForUpdateClause implements Serializable, Cloneable { 33 protected static final ForUpdateClause NO_LOCK_CLAUSE = new ForUpdateClause(); 34 short lockMode; 35 36 public ForUpdateClause() { 37 this.lockMode = ObjectBuildingQuery.NO_LOCK; 38 } 39 40 public ForUpdateClause(short lockMode) { 41 this.lockMode = lockMode; 42 } 43 44 public Object clone() { 45 try { 46 return super.clone(); 47 } catch (CloneNotSupportedException never) { 48 return null; 49 } 50 } 51 52 public static ForUpdateClause newInstance(short lockMode) { 53 if (lockMode == ObjectBuildingQuery.NO_LOCK) { 54 return NO_LOCK_CLAUSE; 55 } else { 56 return new ForUpdateClause(lockMode); 57 } 58 } 59 60 public boolean isForUpdateOfClause() { 61 return false; 62 } 63 64 public boolean isReferenceClassLocked() { 65 return true; 66 } 67 68 public short getLockMode() { 69 return lockMode; 70 } 71 72 76 public void printSQL(ExpressionSQLPrinter printer, SQLSelectStatement statement) { 77 if (getLockMode() == ObjectBuildingQuery.LOCK) { 79 printer.printString(printer.getSession().getPlatform().getSelectForUpdateString()); 80 } else if (lockMode == ObjectBuildingQuery.LOCK_NOWAIT) { 81 printer.printString(printer.getSession().getPlatform().getSelectForUpdateString()); 82 printer.printString(printer.getSession().getPlatform().getSelectForUpdateNoWaitString()); 83 } 84 } 85 } 86 | Popular Tags |