Package com.j256.ormlite.field

Examples of com.j256.ormlite.field.DataType


  /**
   * Add a LIKE clause so the column must mach the value using '%' patterns.
   */
  public Where<T, ID> like(String columnName, Object value) throws SQLException {
    addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
        SimpleComparison.LIKE_OPERATION));
    return this;
  }
View Full Code Here


  /**
   * Add a '&lt;&gt;' clause so the column must be not-equal-to the value.
   */
  public Where<T, ID> ne(String columnName, Object value) throws SQLException {
    addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
        SimpleComparison.NOT_EQUAL_TO_OPERATION));
    return this;
  }
View Full Code Here

   */
  public Where<T, ID> idEq(ID id) throws SQLException {
    if (idColumnName == null) {
      throw new SQLException("Object has no id column specified");
    }
    addClause(new SimpleComparison(idColumnName, idFieldType, id, SimpleComparison.EQUAL_TO_OPERATION));
    return this;
  }
View Full Code Here

   */
  public <OD> Where<T, ID> idEq(Dao<OD, ?> dataDao, OD data) throws SQLException {
    if (idColumnName == null) {
      throw new SQLException("Object has no id column specified");
    }
    addClause(new SimpleComparison(idColumnName, idFieldType, dataDao.extractId(data),
        SimpleComparison.EQUAL_TO_OPERATION));
    return this;
  }
View Full Code Here

      throw SqlExceptionUtil.create("problems rolling back transaction", e);
    }
  }

  public CompiledStatement compileStatement(String statement, StatementType type, FieldType[] argFieldTypes) {
    CompiledStatement stmt = new AndroidCompiledStatement(statement, db, type);
    return stmt;
  }
View Full Code Here

  /**
   * Return the first object that matches the {@link PreparedStmt} or null if none.
   */
  public T queryForFirst(DatabaseConnection databaseConnection, PreparedStmt<T> preparedStmt) throws SQLException {
    CompiledStatement stmt = preparedStmt.compile(databaseConnection);
    try {
      DatabaseResults results = stmt.runQuery();
      if (results.next()) {
        logger.debug("query-for-first of '{}' returned at least 1 result", preparedStmt.getStatement());
        return preparedStmt.mapRow(results);
      } else {
        logger.debug("query-for-first of '{}' returned at 0 results", preparedStmt.getStatement());
        return null;
      }
    } finally {
      if (stmt != null) {
        stmt.close();
      }
    }
  }
View Full Code Here

   * Return a list of all of the data in the table that matches the {@link PreparedStmt}. Should be used carefully if
   * the table is large. Consider using the {@link Dao#iterator} if this is the case.
   */
  public RawResults queryForAllRawOld(ConnectionSource connectionSource, String query) throws SQLException {
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = connection.compileStatement(query, StatementType.SELECT, noFieldTypes);
      String[] columnNames = extractColumnNames(compiledStatement);
      RawResultsWrapper rawResults =
          new RawResultsWrapper(connectionSource, connection, query, compiledStatement, columnNames, this);
      compiledStatement = null;
      connection = null;
      return rawResults;
    } finally {
      if (compiledStatement != null) {
        compiledStatement.close();
      }
      if (connection != null) {
        connectionSource.releaseConnection(connection);
      }
    }
View Full Code Here

   * Create and return an {@link SelectIterator} for the class using a prepared statement.
   */
  public SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> classDao, ConnectionSource connectionSource,
      PreparedStmt<T> preparedStmt) throws SQLException {
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = preparedStmt.compile(connection);
      SelectIterator<T, ID> iterator =
          new SelectIterator<T, ID>(tableInfo.getDataClass(), classDao, preparedStmt, connectionSource,
              connection, compiledStatement, preparedStmt.getStatement());
      connection = null;
      compiledStatement = null;
      return iterator;
    } finally {
      if (compiledStatement != null) {
        compiledStatement.close();
      }
      if (connection != null) {
        connectionSource.releaseConnection(connection);
      }
    }
View Full Code Here

   * Return on old RawResults object associated with an internal iterator that matches the query argument.
   */
  public RawResults buildOldIterator(ConnectionSource connectionSource, String query) throws SQLException {
    logger.debug("executing raw results iterator for: {}", query);
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = connection.compileStatement(query, StatementType.SELECT, noFieldTypes);
      String[] columnNames = extractColumnNames(compiledStatement);
      RawResultsWrapper rawResults =
          new RawResultsWrapper(connectionSource, connection, query, compiledStatement, columnNames, this);
      compiledStatement = null;
      connection = null;
      return rawResults;
    } finally {
      if (compiledStatement != null) {
        compiledStatement.close();
      }
      if (connection != null) {
        connectionSource.releaseConnection(connection);
      }
    }
View Full Code Here

    if (arguments.length > 0) {
      // need to do the (Object) cast to force args to be a single object
      logger.trace("query arguments: {}", (Object) arguments);
    }
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = connection.compileStatement(query, StatementType.SELECT, noFieldTypes);
      assignStatementArguments(compiledStatement, arguments);
      String[] columnNames = extractColumnNames(compiledStatement);
      GenericRawResults<String[]> rawResults =
          new RawResultsImpl<String[]>(connectionSource, connection, query, String[].class,
              compiledStatement, columnNames, this);
      compiledStatement = null;
      connection = null;
      return rawResults;
    } finally {
      if (compiledStatement != null) {
        compiledStatement.close();
      }
      if (connection != null) {
        connectionSource.releaseConnection(connection);
      }
    }
View Full Code Here

TOP

Related Classes of com.j256.ormlite.field.DataType

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.