use of org.eclipse.persistence.queries.DirectReadQuery in project eclipselink by eclipse-ee4j.
the class DirectMapMapping method initializeSelectionStatement.
@Override
protected void initializeSelectionStatement(AbstractSession session) {
if (this.selectionQuery.isReadAllQuery()) {
((ReadAllQuery) this.selectionQuery).addAdditionalField(getDirectField().clone());
} else {
SQLSelectStatement statement = (SQLSelectStatement) this.selectionQuery.getSQLStatement();
statement.addTable(getReferenceTable());
statement.addField(getDirectField().clone());
getContainerPolicy().addAdditionalFieldsToQuery(this.selectionQuery, getAdditionalFieldsBaseExpression(this.selectionQuery));
statement.normalize(session, null);
}
if (this.selectionQuery.isDirectReadQuery()) {
((DirectReadQuery) this.selectionQuery).setResultType(DataReadQuery.MAP);
}
}
use of org.eclipse.persistence.queries.DirectReadQuery in project eclipselink by eclipse-ee4j.
the class ContainerPolicy method buildSelectionQueryForDirectCollectionMapping.
/**
* INTERNAL:
* This
* Certain key mappings favor different types of selection query. Return the appropriate
* type of selectionQuery
*/
public ReadQuery buildSelectionQueryForDirectCollectionMapping() {
DirectReadQuery query = new DirectReadQuery();
query.setSQLStatement(new SQLSelectStatement());
query.setContainerPolicy(this);
return query;
}
use of org.eclipse.persistence.queries.DirectReadQuery in project eclipselink by eclipse-ee4j.
the class RelationTableMechanism method initializeLockRelationTableQuery.
/**
* INTERNAL:
* Initialize lockRelationTableQuery.
*/
protected void initializeLockRelationTableQuery(AbstractSession session, ForeignReferenceMapping mapping, Expression startCriteria) {
lockRelationTableQuery = new DirectReadQuery();
Expression criteria = buildSelectionCriteriaAndAddFieldsToQueryInternal(mapping, startCriteria, false, false);
SQLSelectStatement statement = new SQLSelectStatement();
statement.addTable(this.relationTable);
statement.addField(this.sourceRelationKeyFields.get(0).clone());
statement.setWhereClause(criteria);
statement.normalize(session, null);
lockRelationTableQuery.setSQLStatement(statement);
lockRelationTableQuery.setSessionName(session.getName());
}
use of org.eclipse.persistence.queries.DirectReadQuery in project eclipselink by eclipse-ee4j.
the class RelationTableMechanism method getLockRelationTableQueryClone.
/**
* 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;
}
Aggregations