All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.query.SqlTreeNodeFormulaWhereJoin Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.query;

import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.server.deploy.DbSqlContext;

import java.util.List;
import java.util.Set;

/**
 * Join to Many (or child of a many) to support where clause predicates on many properties.
 */
final class SqlTreeNodeFormulaWhereJoin implements SqlTreeNode {

  private final STreeProperty nodeBeanProp;

  /**
   * The many where join which is either INNER or OUTER.
   */
  private final SqlJoinType manyJoinType;

  /**
   * This is a many where formula join
   */
  private final String manyWhere;

  SqlTreeNodeFormulaWhereJoin(STreeProperty prop, SqlJoinType manyJoinType, String manyWhere) {
    this.nodeBeanProp = prop;
    this.manyJoinType = manyJoinType;
    this.manyWhere = manyWhere;
  }

  @Override
  public SqlTreeLoad createLoad() {
    return null;
  }

  @Override
  public boolean isSingleProperty() {
    return true;
  }

  @Override
  public void addAsOfTableAlias(SpiQuery query) {
    // do nothing here ...
  }

  @Override
  public void addSoftDeletePredicate(SpiQuery query) {
    // do nothing here ...
  }

  @Override
  public boolean isAggregation() {
    return false;
  }

  @Override
  public void appendDistinctOn(DbSqlContext ctx, boolean subQuery) {
    // do nothing here ...
  }

  @Override
  public void appendGroupBy(DbSqlContext ctx, boolean subQuery) {
    // do nothing here
  }

  /**
   * Append to the FROM clause for this node.
   */
  @Override
  public void appendFrom(DbSqlContext ctx, SqlJoinType currentJoinType) {
    // always use the join type as per this many where join
    // (OUTER for disjunction and otherwise INNER)
    nodeBeanProp.appendFrom(ctx, manyJoinType, manyWhere);
  }

  @Override
  public void dependentTables(Set tables) {
    // FIXME: we cannot easily determine the dependent tables this would require an enhancement
    // of the @Formula(dependentTables=...) annotation
  }

  @Override
  public void buildRawSqlSelectChain(List selectChain) {
    // nothing to add
  }

  @Override
  public void appendSelect(DbSqlContext ctx, boolean subQuery) {
    // nothing to do here
  }

  @Override
  public void appendWhere(DbSqlContext ctx) {
    // nothing to do here
  }

  @Override
  public boolean hasMany() {
    return true;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy