/** * INTERNAL: * Returns a query that */ ReadQuery getLockRelationTableQueryClone(AbstractSession session, short lockMode) { DirectReadQuery lockRelationTableQueryClone = (DirectReadQuery)lockRelationTableQuery.clone(); SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(this.relationTable); statement.addField(this.sourceRelationKeyFields.get(0).clone()); statement.setWhereClause((Expression)lockRelationTableQuery.getSelectionCriteria().clone()); statement.setLockingClause(new ForUpdateClause(lockMode)); statement.normalize(session, null); lockRelationTableQueryClone.setSQLStatement(statement); lockRelationTableQueryClone.setIsExecutionClone(true); return lockRelationTableQueryClone; }
/** * INTERNAL: * Returns a query that */ ReadQuery getLockRelationTableQueryClone(AbstractSession session, short lockMode) { DirectReadQuery lockRelationTableQueryClone = (DirectReadQuery)lockRelationTableQuery.clone(); SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(this.relationTable); statement.addField((DatabaseField)this.sourceRelationKeyFields.get(0).clone()); statement.setWhereClause((Expression)lockRelationTableQuery.getSelectionCriteria().clone()); statement.setLockingClause(new ForUpdateClause(lockMode)); statement.normalize(session, null); lockRelationTableQueryClone.setSQLStatement(statement); lockRelationTableQueryClone.setIsExecutionClone(true); return lockRelationTableQueryClone; }
/** * INTERNAL: * Returns a query that */ ReadQuery getLockRelationTableQueryClone(AbstractSession session, short lockMode) { DirectReadQuery lockRelationTableQueryClone = (DirectReadQuery)lockRelationTableQuery.clone(); SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(this.relationTable); statement.addField(this.sourceRelationKeyFields.get(0).clone()); statement.setWhereClause((Expression)lockRelationTableQuery.getSelectionCriteria().clone()); statement.setLockingClause(new ForUpdateClause(lockMode)); statement.normalize(session, null); lockRelationTableQueryClone.setSQLStatement(statement); lockRelationTableQueryClone.setIsExecutionClone(true); return lockRelationTableQueryClone; }
/** * 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; }
ObjectLevelReadQuery query = (ObjectLevelReadQuery)getQuery(); selectStatement.setQuery(query); selectStatement.setLockingClause(query.getLockingClause()); selectStatement.setDistinctState(query.getDistinctState()); selectStatement.setTables((Vector)getDescriptor().getTables().clone());
ObjectLevelReadQuery query = (ObjectLevelReadQuery)getQuery(); selectStatement.setQuery(query); selectStatement.setLockingClause(query.getLockingClause()); selectStatement.setDistinctState(query.getDistinctState()); selectStatement.setTables((Vector)getDescriptor().getTables().clone());
ObjectLevelReadQuery query = (ObjectLevelReadQuery)getQuery(); selectStatement.setQuery(query); selectStatement.setLockingClause(query.getLockingClause()); selectStatement.setDistinctState(query.getDistinctState()); selectStatement.setTables((Vector)getDescriptor().getTables().clone());
statement.setLockingClause(new ForUpdateClause(sourceQuery.getLockMode()));
statement.setLockingClause(new ForUpdateClause(sourceQuery.getLockMode()));
statement.setLockingClause(new ForUpdateClause(sourceQuery.getLockMode()));