Package com.j256.ormlite.stmt

Examples of com.j256.ormlite.stmt.ArgumentHolder


    return true;
  }

  public ID extractId(T data) throws SQLException {
    checkForInitialized();
    FieldType idField = tableInfo.getIdField();
    @SuppressWarnings("unchecked")
    ID id = (ID) idField.extractJavaFieldValue(data);
    return id;
  }
View Full Code Here


    boolean appendSpace = true;
    if (argOrValue == null) {
      throw new SQLException("argument to comparison of '" + fieldType.getFieldName() + "' is null");
    } else if (argOrValue instanceof ArgumentHolder) {
      sb.append('?');
      ArgumentHolder selectArg = (ArgumentHolder) argOrValue;
      selectArg.setMetaInfo(columnName, fieldType);
      argList.add(selectArg);
    } else if (fieldType.isSelectArgRequired()) {
      sb.append('?');
      ArgumentHolder selectArg = new SelectArg();
      selectArg.setMetaInfo(columnName, fieldType);
      // conversion is done when the getValue() is called
      selectArg.setValue(argOrValue);
      argList.add(selectArg);
    } else if (fieldType.isForeign() && fieldType.getFieldType() == argOrValue.getClass()) {
      /*
       * If we have a foreign field and our argument is an instance of the foreign object (i.e. not its id), then
       * we need to extract the id.
View Full Code Here

    boolean appendSpace = true;
    if (argOrValue == null) {
      throw new SQLException("argument for '" + fieldType.getFieldName() + "' is null");
    } else if (argOrValue instanceof ArgumentHolder) {
      sb.append('?');
      ArgumentHolder argHolder = (ArgumentHolder) argOrValue;
      argHolder.setMetaInfo(columnName, fieldType);
      argList.add(argHolder);
    } else if (argOrValue instanceof ColumnArg) {
      ColumnArg columnArg = (ColumnArg) argOrValue;
      String tableName = columnArg.getTableName();
      if (tableName != null) {
        databaseType.appendEscapedEntityName(sb, tableName);
        sb.append('.');
      }
      databaseType.appendEscapedEntityName(sb, columnArg.getColumnName());
    } else if (fieldType.isArgumentHolderRequired()) {
      sb.append('?');
      ArgumentHolder argHolder = new SelectArg();
      argHolder.setMetaInfo(columnName, fieldType);
      // conversion is done when the getValue() is called
      argHolder.setValue(argOrValue);
      argList.add(argHolder);
    } else if (fieldType.isForeign() && fieldType.getType().isAssignableFrom(argOrValue.getClass())) {
      /*
       * If we have a foreign field and our argument is an instance of the foreign object (i.e. not its id), then
       * we need to extract the id. We allow super-classes of the field but not sub-classes.
View Full Code Here

   * <b>NOTE:</b> I couldn't remove the code warning associated with this method when used with more than 2 arguments.
   * </p>
   */
  public Where<T, ID> and(Where<T, ID> first, Where<T, ID> second, Where<T, ID>... others) {
    Clause[] clauses = buildClauseArray(others, "AND");
    Clause secondClause = pop("AND");
    Clause firstClause = pop("AND");
    addClause(new ManyClause(firstClause, secondClause, clauses, ManyClause.AND_OPERATION));
    return this;
  }
View Full Code Here

   * <b>NOTE:</b> I can't remove the code warning associated with this method. Use the iterator method below.
   * </p>
   */
  public Where<T, ID> or(Where<T, ID> left, Where<T, ID> right, Where<T, ID>... others) {
    Clause[] clauses = buildClauseArray(others, "OR");
    Clause secondClause = pop("OR");
    Clause firstClause = pop("OR");
    addClause(new ManyClause(firstClause, secondClause, clauses, ManyClause.OR_OPERATION));
    return this;
  }
View Full Code Here

  @Override
  public String toString() {
    if (clauseStackLevel == 0) {
      return "empty where clause";
    } else {
      Clause clause = peek();
      return "where clause: " + clause;
    }
  }
View Full Code Here

  private Clause pop(String label) {
    if (clauseStackLevel == 0) {
      throw new IllegalStateException("Expecting there to be a clause already defined for '" + label
          + "' operation");
    }
    Clause clause = clauseStack[--clauseStackLevel];
    // to help gc
    clauseStack[clauseStackLevel] = null;
    return clause;
  }
View Full Code Here

   * </p>
   */
  public Where<T, ID> exists(QueryBuilder<?, ?> subQueryBuilder) throws SQLException {
    // we do this to turn off the automatic addition of the ID column in the select column list
    subQueryBuilder.enableInnerQuery();
    addClause(new Exists(new InternalQueryBuilderWrapper(subQueryBuilder)));
    return this;
  }
View Full Code Here

  /**
   * Add a IN clause so the column must be equal-to one of the objects from the list passed in.
   */
  public Where<T, ID> in(String columnName, Iterable<?> objects) throws SQLException {
    addClause(new In(columnName, findColumnFieldType(columnName), objects));
    return this;
  }
View Full Code Here

   */
  public Where<T, ID> in(String columnName, Object... objects) throws SQLException {
    if (objects.length == 1 && objects[0].getClass().isArray()) {
      throw new IllegalArgumentException("in(Object... objects) seems to be an array within an array");
    }
    addClause(new In(columnName, findColumnFieldType(columnName), objects));
    return this;
  }
View Full Code Here

TOP

Related Classes of com.j256.ormlite.stmt.ArgumentHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.