Search in sources :

Example 1 with JoinTreeNode

use of org.apache.cayenne.access.translator.select.JoinTreeNode in project cayenne by apache.

the class OpenBaseJoinStack method appendQualifierSubtree.

protected void appendQualifierSubtree(StringBuilder out, JoinTreeNode node) {
    DbRelationship relationship = node.getRelationship();
    String srcAlias = node.getSourceTableAlias();
    String targetAlias = node.getTargetTableAlias();
    List<DbJoin> joins = relationship.getJoins();
    int len = joins.size();
    for (int i = 0; i < len; i++) {
        DbJoin join = joins.get(i);
        if (i > 0) {
            out.append(" AND ");
        }
        out.append(srcAlias).append('.').append(join.getSourceName());
        switch(node.getJoinType()) {
            case INNER:
                out.append(" = ");
                break;
            case LEFT_OUTER:
                out.append(" * ");
                break;
            default:
                throw new IllegalArgumentException("Unsupported join type: " + node.getJoinType());
        }
        out.append(targetAlias).append('.').append(join.getTargetName());
    }
    for (JoinTreeNode child : node.getChildren()) {
        out.append(" AND ");
        appendQualifierSubtree(out, child);
    }
}
Also used : DbRelationship(org.apache.cayenne.map.DbRelationship) DbJoin(org.apache.cayenne.map.DbJoin) JoinTreeNode(org.apache.cayenne.access.translator.select.JoinTreeNode)

Example 2 with JoinTreeNode

use of org.apache.cayenne.access.translator.select.JoinTreeNode in project cayenne by apache.

the class Oracle8JoinStack method appendJoinSubtree.

@Override
protected void appendJoinSubtree(StringBuilder out, JoinTreeNode node) {
    DbRelationship relationship = node.getRelationship();
    if (relationship == null) {
        return;
    }
    DbEntity targetEntity = relationship.getTargetEntity();
    String targetAlias = node.getTargetTableAlias();
    out.append(", ").append(targetEntity.getFullyQualifiedName()).append(' ').append(targetAlias);
    for (JoinTreeNode child : node.getChildren()) {
        appendJoinSubtree(out, child);
    }
}
Also used : DbEntity(org.apache.cayenne.map.DbEntity) DbRelationship(org.apache.cayenne.map.DbRelationship) JoinTreeNode(org.apache.cayenne.access.translator.select.JoinTreeNode)

Example 3 with JoinTreeNode

use of org.apache.cayenne.access.translator.select.JoinTreeNode in project cayenne by apache.

the class Oracle8JoinStack method appendQualifier.

@Override
protected void appendQualifier(StringBuilder out, boolean firstQualifierElement) {
    boolean first = firstQualifierElement;
    for (JoinTreeNode node : rootNode.getChildren()) {
        if (!first) {
            out.append(" AND ");
        }
        appendQualifierSubtree(out, node);
        first = false;
    }
}
Also used : JoinTreeNode(org.apache.cayenne.access.translator.select.JoinTreeNode)

Example 4 with JoinTreeNode

use of org.apache.cayenne.access.translator.select.JoinTreeNode in project cayenne by apache.

the class OpenBaseJoinStack method appendQualifier.

@Override
protected void appendQualifier(StringBuilder out, boolean firstQualifierElement) {
    boolean first = firstQualifierElement;
    for (JoinTreeNode node : rootNode.getChildren()) {
        if (!first) {
            out.append(" AND ");
        }
        appendQualifierSubtree(out, node);
        first = false;
    }
}
Also used : JoinTreeNode(org.apache.cayenne.access.translator.select.JoinTreeNode)

Example 5 with JoinTreeNode

use of org.apache.cayenne.access.translator.select.JoinTreeNode in project cayenne by apache.

the class OpenBaseJoinStack method appendJoinSubtree.

@Override
protected void appendJoinSubtree(StringBuilder out, JoinTreeNode node) {
    DbRelationship relationship = node.getRelationship();
    if (relationship == null) {
        return;
    }
    DbEntity targetEntity = relationship.getTargetEntity();
    String targetAlias = node.getTargetTableAlias();
    out.append(", ").append(targetEntity.getFullyQualifiedName()).append(' ').append(targetAlias);
    for (JoinTreeNode child : node.getChildren()) {
        appendJoinSubtree(out, child);
    }
}
Also used : DbEntity(org.apache.cayenne.map.DbEntity) DbRelationship(org.apache.cayenne.map.DbRelationship) JoinTreeNode(org.apache.cayenne.access.translator.select.JoinTreeNode)

Aggregations

JoinTreeNode (org.apache.cayenne.access.translator.select.JoinTreeNode)6 DbRelationship (org.apache.cayenne.map.DbRelationship)4 DbEntity (org.apache.cayenne.map.DbEntity)2 DbJoin (org.apache.cayenne.map.DbJoin)2