/** * PUBLIC: * Sets whether this is a pessimistically locking query. * <ul> * <li>ObjectBuildingQuery.LOCK: SELECT .... FOR UPDATE issued. * <li>ObjectBuildingQuery.LOCK_NOWAIT: SELECT .... FOR UPDATE NO WAIT issued. * <li>ObjectBuildingQuery.NO_LOCK: no pessimistic locking. * <li>ObjectBuildingQuery.DEFAULT_LOCK_MODE (default) and you have a CMP descriptor: * fine grained locking will occur. * </ul> * <p>Fine Grained Locking: On execution the reference class * and those of all joined attributes will be checked. If any of these have a * PessimisticLockingPolicy set on their descriptor, they will be locked in a * SELECT ... FOR UPDATE OF ... {NO WAIT}. Issues fewer locks * and avoids setting the lock mode on each query. * <p>Example:<code>readAllQuery.setSelectionCriteria(employee.get("address").equal("Ottawa"));</code> * <ul><li>LOCK: all employees in Ottawa and all referenced Ottawa addresses will be locked. * <li>DEFAULT_LOCK_MODE: if address is a joined attribute, and only address has a pessimistic * locking policy, only referenced Ottawa addresses will be locked. * </ul> * @see org.eclipse.persistence.descriptors.PessimisticLockingPolicy */ public void setLockMode(short lockMode) { lockingClause = ForUpdateClause.newInstance(lockMode); }
/** * PUBLIC: * Sets whether this is a pessimistically locking query. * <ul> * <li>ObjectBuildingQuery.LOCK: SELECT .... FOR UPDATE issued. * <li>ObjectBuildingQuery.LOCK_NOWAIT: SELECT .... FOR UPDATE NO WAIT issued. * <li>ObjectBuildingQuery.NO_LOCK: no pessimistic locking. * <li>ObjectBuildingQuery.DEFAULT_LOCK_MODE (default) and you have a CMP descriptor: * fine grained locking will occur. * </ul> * <p>Fine Grained Locking: On execution the reference class * and those of all joined attributes will be checked. If any of these have a * PessimisticLockingPolicy set on their descriptor, they will be locked in a * SELECT ... FOR UPDATE OF ... {NO WAIT}. Issues fewer locks * and avoids setting the lock mode on each query. * <p>Example:<code>readAllQuery.setSelectionCriteria(employee.get("address").equal("Ottawa"));</code> * <ul><li>LOCK: all employees in Ottawa and all referenced Ottawa addresses will be locked. * <li>DEFAULT_LOCK_MODE: if address is a joined attribute, and only address has a pessimistic * locking policy, only referenced Ottawa addresses will be locked. * </ul> * @see org.eclipse.persistence.descriptors.PessimisticLockingPolicy */ public void setLockMode(short lockMode) { lockingClause = ForUpdateClause.newInstance(lockMode); }
/** * PUBLIC: * Sets whether this is a pessimistically locking query. * <ul> * <li>ObjectBuildingQuery.LOCK: SELECT .... FOR UPDATE issued. * <li>ObjectBuildingQuery.LOCK_NOWAIT: SELECT .... FOR UPDATE NO WAIT issued. * <li>ObjectBuildingQuery.NO_LOCK: no pessimistic locking. * <li>ObjectBuildingQuery.DEFAULT_LOCK_MODE (default) and you have a CMP descriptor: * fine grained locking will occur. * </ul> * <p>Fine Grained Locking: On execution the reference class * and those of all joined attributes will be checked. If any of these have a * PessimisticLockingPolicy set on their descriptor, they will be locked in a * SELECT ... FOR UPDATE OF ... {NO WAIT}. Issues fewer locks * and avoids setting the lock mode on each query. * <p>Example:<code>readAllQuery.setSelectionCriteria(employee.get("address").equal("Ottawa"));</code> * <ul><li>LOCK: all employees in Ottawa and all referenced Ottawa addresses will be locked. * <li>DEFAULT_LOCK_MODE: if address is a joined attribute, and only address has a pessimistic * locking policy, only referenced Ottawa addresses will be locked. * </ul> * @see org.eclipse.persistence.descriptors.PessimisticLockingPolicy */ public void setLockMode(short lockMode) { lockingClause = ForUpdateClause.newInstance(lockMode); }
lockingClause = ForUpdateClause.newInstance(lockMode); setShouldRefreshIdentityMapResult(true); } else if (lockMode == NO_LOCK) { lockingClause = ForUpdateClause.newInstance(lockMode); } else { lockingClause = null;
lockingClause = ForUpdateClause.newInstance(lockMode); setShouldRefreshIdentityMapResult(true); } else if (lockMode == NO_LOCK) { lockingClause = ForUpdateClause.newInstance(lockMode); } else { lockingClause = null;
lockingClause = ForUpdateClause.newInstance(lockMode); setShouldRefreshIdentityMapResult(true); } else if (lockMode == NO_LOCK) { lockingClause = ForUpdateClause.newInstance(lockMode); } else { lockingClause = null;
setLockMode(ObjectBuildingQuery.LOCK_NOWAIT); } else { lockingClause = ForUpdateClause.newInstance(timeout); this.lockingClause = ForUpdateClause.newInstance(NO_LOCK); } else { this.lockingClause = lockingClause;
/** * Build the select statement for selecting the locator */ private SQLSelectStatement buildSelectStatementForLocator(WriteObjectQuery writeQuery, DatabaseCall call, AbstractSession session) { SQLSelectStatement selectStatement = new SQLSelectStatement(); Vector tables = writeQuery.getDescriptor().getTables(); selectStatement.setTables(tables); //rather than get ALL fields from the descriptor, only use the LOB-related fields to build the minimal SELECT statement. selectStatement.setFields(call.getContexts().getFields()); //the where clause setting here is sufficient if the object does not map to multiple tables. selectStatement.setWhereClause(writeQuery.getDescriptor().getObjectBuilder().buildPrimaryKeyExpressionFromObject(writeQuery.getObject(), session)); //need pessimistic locking for the locator select selectStatement.setLockingClause(ForUpdateClause.newInstance(ObjectBuildingQuery.LOCK)); if (tables.size() > 1) { //the primary key expression from the primary table Expression expression = selectStatement.getWhereClause(); //additional join from the non-primary tables Expression additionalJoin = writeQuery.getDescriptor().getQueryManager().getAdditionalJoinExpression(); if (additionalJoin != null) { expression = expression.and(additionalJoin); } //where clause now contains extra joins across all tables selectStatement.setWhereClause(expression); } //normalize the statement at the end, such as assign alias to all tables, and build sorting statement selectStatement.normalize(session, writeQuery.getDescriptor()); return selectStatement; }
/** * Build the select statement for selecting the locator */ private SQLSelectStatement buildSelectStatementForLocator(WriteObjectQuery writeQuery, DatabaseCall call, AbstractSession session) { SQLSelectStatement selectStatement = new SQLSelectStatement(); Vector tables = writeQuery.getDescriptor().getTables(); selectStatement.setTables(tables); //rather than get ALL fields from the descriptor, only use the LOB-related fields to build the minimal SELECT statement. selectStatement.setFields(call.getContexts().getFields()); //the where clause setting here is sufficient if the object does not map to multiple tables. selectStatement.setWhereClause(writeQuery.getDescriptor().getObjectBuilder().buildPrimaryKeyExpressionFromObject(writeQuery.getObject(), session)); //need pessimistic locking for the locator select selectStatement.setLockingClause(ForUpdateClause.newInstance(ObjectBuildingQuery.LOCK)); if (tables.size() > 1) { //the primary key expression from the primary table Expression expression = selectStatement.getWhereClause(); //additional join from the non-primary tables Expression additionalJoin = writeQuery.getDescriptor().getQueryManager().getAdditionalJoinExpression(); if (additionalJoin != null) { expression = expression.and(additionalJoin); } //where clause now contains extra joins across all tables selectStatement.setWhereClause(expression); } //normalize the statement at the end, such as assign alias to all tables, and build sorting statement selectStatement.normalize(session, writeQuery.getDescriptor()); return selectStatement; }
/** * Build the select statement for selecting the locator */ private SQLSelectStatement buildSelectStatementForLocator(WriteObjectQuery writeQuery, DatabaseCall call, AbstractSession session) { SQLSelectStatement selectStatement = new SQLSelectStatement(); Vector tables = writeQuery.getDescriptor().getTables(); selectStatement.setTables(tables); //rather than get ALL fields from the descriptor, only use the LOB-related fields to build the minimal SELECT statement. selectStatement.setFields(call.getContexts().getFields()); //the where clause setting here is sufficient if the object does not map to multiple tables. selectStatement.setWhereClause(writeQuery.getDescriptor().getObjectBuilder().buildPrimaryKeyExpressionFromObject(writeQuery.getObject(), session)); //need pessimistic locking for the locator select selectStatement.setLockingClause(ForUpdateClause.newInstance(ObjectBuildingQuery.LOCK)); if (tables.size() > 1) { //the primary key expression from the primary table Expression expression = selectStatement.getWhereClause(); //additional join from the non-primary tables Expression additionalJoin = writeQuery.getDescriptor().getQueryManager().getAdditionalJoinExpression(); if (additionalJoin != null) { expression = expression.and(additionalJoin); } //where clause now contains extra joins across all tables selectStatement.setWhereClause(expression); } //normalize the statement at the end, such as assign alias to all tables, and build sorting statement selectStatement.normalize(session, writeQuery.getDescriptor()); return selectStatement; }
setLockMode(ObjectBuildingQuery.LOCK_NOWAIT); } else { this.lockingClause = ForUpdateClause.newInstance(timeout);
setLockMode(ObjectBuildingQuery.LOCK_NOWAIT); } else { this.lockingClause = ForUpdateClause.newInstance(timeout);