blob: 915df35feef967c2d47373b2e561f151357f9757 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.jdbc.sql;
import org.apache.openjpa.jdbc.meta.ClassMapping;
import org.apache.openjpa.jdbc.schema.ForeignKey;
import org.apache.openjpa.jdbc.schema.Table;
import org.apache.openjpa.kernel.exps.Context;
/**
* Tracks joins made when traversing relations in a select.
*
* @author Abe White
*/
public interface Joins {
/**
* Whether we have any joins.
*/
boolean isEmpty();
/**
* Whether this joins path results in outer joins.
*/
boolean isOuter();
/**
* Perform a cross join on the given tables.
*/
Joins crossJoin(Table localTable, Table foreignTable);
/**
* Join the columns of the given foreign key.
*/
Joins join(ForeignKey fk, boolean inverse, boolean toMany);
/**
* Join the columns of the given foreign key.
*/
Joins outerJoin(ForeignKey fk, boolean inverse, boolean toMany);
/**
* Join the columns of the given foreign key, which represents a relation
* via the given field name.
*/
Joins joinRelation(String name, ForeignKey fk, ClassMapping target,
int subclasses, boolean inverse, boolean toMany);
/**
* Join the columns of the given foreign key, which represents a relation
* via the given field name.
*/
Joins outerJoinRelation(String name, ForeignKey fk,
ClassMapping target, int subclasses, boolean inverse, boolean toMany);
/**
* Set the variable name being traversed into with the next join.
*/
Joins setVariable(String var);
/**
* Set the subquery alias.
*/
Joins setSubselect(String alias);
/**
* Set subquery context when traversing into the next join is
* in transition from parent context to subquery.
* @param context
*/
Joins setJoinContext(Context context);
/**
* Set the correlated variable name being traversed into
* with the next join.
*/
Joins setCorrelatedVariable(String var);
/**
* Return correlated variable name
*/
String getCorrelatedVariable();
/**
* Move joins that belong to subquery's parent
*/
void moveJoinsToParent();
}