Search in sources :

Example 1 with DirectReadQuery

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);
    }
}
Also used : ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) SQLSelectStatement(org.eclipse.persistence.internal.expressions.SQLSelectStatement) DirectReadQuery(org.eclipse.persistence.queries.DirectReadQuery)

Example 2 with DirectReadQuery

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;
}
Also used : SQLSelectStatement(org.eclipse.persistence.internal.expressions.SQLSelectStatement) DirectReadQuery(org.eclipse.persistence.queries.DirectReadQuery)

Example 3 with DirectReadQuery

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());
}
Also used : FieldExpression(org.eclipse.persistence.internal.expressions.FieldExpression) Expression(org.eclipse.persistence.expressions.Expression) SQLSelectStatement(org.eclipse.persistence.internal.expressions.SQLSelectStatement) DirectReadQuery(org.eclipse.persistence.queries.DirectReadQuery)

Example 4 with DirectReadQuery

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;
}
Also used : SQLSelectStatement(org.eclipse.persistence.internal.expressions.SQLSelectStatement) ForUpdateClause(org.eclipse.persistence.internal.expressions.ForUpdateClause) DirectReadQuery(org.eclipse.persistence.queries.DirectReadQuery)

Aggregations

SQLSelectStatement (org.eclipse.persistence.internal.expressions.SQLSelectStatement)4 DirectReadQuery (org.eclipse.persistence.queries.DirectReadQuery)4 Expression (org.eclipse.persistence.expressions.Expression)1 FieldExpression (org.eclipse.persistence.internal.expressions.FieldExpression)1 ForUpdateClause (org.eclipse.persistence.internal.expressions.ForUpdateClause)1 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)1