Package com.j256.ormlite.field

Examples of com.j256.ormlite.field.DatabaseFieldConfigTest$Serial


    logger.debug("executing raw query for: {}", query);
    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);
      RawResultsImpl<Object[]> rawResults =
          new RawResultsImpl<Object[]>(connectionSource, connection, query, Object[].class,
              compiledStatement, columnNames, new ObjectArrayRowMapper(columnTypes));
View Full Code Here


    }
  }

  private static <T> int clearTable(ConnectionSource connectionSource, String tableName) throws SQLException {
    DatabaseType databaseType = connectionSource.getDatabaseType();
    DatabaseConnection connection = connectionSource.getReadWriteConnection();
    StringBuilder sb = new StringBuilder(48);
    if (databaseType.isTruncateSupported()) {
      sb.append("TRUNCATE TABLE ");
    } else {
      sb.append("DELETE FROM ");
    }
    databaseType.appendEscapedEntityName(sb, tableName);
    String statement = sb.toString();
    logger.info("clearing table '{}' with '{}", tableName, statement);
    CompiledStatement compiledStmt = null;
    try {
      compiledStmt = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes);
      return compiledStmt.runExecute();
    } finally {
      if (compiledStmt != null) {
        compiledStmt.close();
      }
View Full Code Here

      TableInfo<T, ID> tableInfo, boolean ignoreErrors) throws SQLException {
    logger.info("dropping table '{}'", tableInfo.getTableName());
    List<String> statements = new ArrayList<String>();
    addDropIndexStatements(databaseType, tableInfo, statements);
    addDropTableStatements(databaseType, tableInfo, statements);
    DatabaseConnection connection = connectionSource.getReadWriteConnection();
    try {
      return doStatements(connection, "drop", statements, ignoreErrors, false);
    } finally {
      connectionSource.releaseConnection(connection);
    }
View Full Code Here

    DatabaseType databaseType = connectionSource.getDatabaseType();
    logger.info("creating table '{}'", tableInfo.getTableName());
    List<String> statements = new ArrayList<String>();
    List<String> queriesAfter = new ArrayList<String>();
    addCreateTableStatements(databaseType, tableInfo, statements, queriesAfter, ifNotExists);
    DatabaseConnection connection = connectionSource.getReadWriteConnection();
    try {
      int stmtC = doStatements(connection, "create", statements, false, databaseType.isCreateTableReturnsZero());
      stmtC += doCreateTestQueries(connection, databaseType, queriesAfter);
      return stmtC;
    } finally {
View Full Code Here

    initialized = true;
  }

  public T queryForId(ID id) throws SQLException {
    checkForInitialized();
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    try {
      return statementExecutor.queryForId(connection, id);
    } finally {
      connectionSource.releaseConnection(connection);
    }
View Full Code Here

    }
  }

  public T queryForFirst(PreparedQuery<T> preparedQuery) throws SQLException {
    checkForInitialized();
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    try {
      return statementExecutor.queryForFirst(connection, preparedQuery);
    } finally {
      connectionSource.releaseConnection(connection);
    }
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;
View Full Code Here

    // now execute any test queries which test the newly created table
    for (String query : queriesAfter) {
      CompiledStatement compiledStmt = null;
      try {
        compiledStmt = connection.compileStatement(query, StatementType.EXECUTE, noFieldTypes);
        DatabaseResults results = compiledStmt.runQuery();
        int rowC = 0;
        // count the results
        while (results.next()) {
          rowC++;
        }
        logger.info("executing create table after-query got {} results: {}", rowC, query);
      } catch (SQLException e) {
        // we do this to make sure that the statement is in the exception
View Full Code Here

      @SuppressWarnings("unchecked")
      D castDao = (D) dao;
      return castDao;
    }

    DatabaseTable databaseTable = clazz.getAnnotation(DatabaseTable.class);
    if (databaseTable == null || databaseTable.daoClass() == Void.class
        || databaseTable.daoClass() == BaseDaoImpl.class) {
      @SuppressWarnings("deprecation")
      Dao<T, ?> daoTmp = BaseDaoImpl.createDao(connectionSource, clazz);
      dao = daoTmp;
    } else {
      Class<?> daoClass = databaseTable.daoClass();
      Constructor<?> daoConstructor = null;
      Object[] arguments = null;
      Constructor<?>[] constructors = daoClass.getConstructors();
      // look first for the constructor with a class parameter in case it is a generic dao
      for (Constructor<?> constructor : constructors) {
View Full Code Here

      @SuppressWarnings("unchecked")
      D castDao = (D) dao;
      return castDao;
    }

    DatabaseTable databaseTable = tableConfig.getDataClass().getAnnotation(DatabaseTable.class);
    if (databaseTable == null || databaseTable.daoClass() == Void.class
        || databaseTable.daoClass() == BaseDaoImpl.class) {
      @SuppressWarnings("deprecation")
      Dao<T, ?> daoTmp = BaseDaoImpl.createDao(connectionSource, tableConfig);
      dao = daoTmp;
    } else {
      Class<?> daoClass = databaseTable.daoClass();
      Constructor<?> constructor;
      try {
        constructor = daoClass.getConstructor(ConnectionSource.class, DatabaseTableConfig.class);
      } catch (Exception e) {
        throw SqlExceptionUtil.create(
View Full Code Here

TOP

Related Classes of com.j256.ormlite.field.DatabaseFieldConfigTest$Serial

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.