UniqueList<FromElement> queryFromClause = query.getFromClause();
UniqueList<String> queryWhereClause = query.getWhereClause();
for (int i = 0; i < criteriaJoins.size(); i++)
{
Join join = criteriaJoins.get(i);
// Check the join type and add the join to the
// appropriate places in the query
JoinType joinType = join.getJoinType();
if (joinType == null)
{
// Do not treat join as explicit join, but add
// the join condition to the where clauses
StringBuilder joinConditionStringBuilder = new StringBuilder();
SqlBuilder.appendCriterion(
join.getJoinCondition(),
criteria,
joinConditionStringBuilder,
query);
queryWhereClause.add(joinConditionStringBuilder.toString());
}
else
{
Criterion joinCondition = join.getJoinCondition();
// get the table names
// (and the alias names for them if necessary))
PreparedStatementPart leftExpression;
if (join.getLeftTable() != null)
{
leftExpression = join.getLeftTable();
}
else
{
if (joinCondition.isComposite())
{
throw new TorqueException(
"join condition is composite "
+ "and there is no leftTable defined "
+ "in the join. "
+ "Please define a leftTable in the join");
}
Object lValue = joinCondition.getLValue();
leftExpression = SqlBuilder.getExpressionForFromClause(
lValue,
criteria);
}
PreparedStatementPart rightExpression;
if (join.getRightTable() != null)
{
rightExpression = join.getRightTable();
}
else
{
if (joinCondition.isComposite())
{