/* (non-Javadoc)
@see org.jadira.usertype.dateandtime.shared.spi.ColumnMapper#jdbcClass()
760452
@Override
    public final Class<J> jdbcClass() {
        @SuppressWarnings("unchecked")
        Class<J> result = (Class<J>) TypeHelper.getTypeArguments(ColumnMapper.class, getClass()).get(1);
        return result;
    }
1082040
@Override
    public JdbcQueue<ID, DATA> init() throws Exception {
        SQL_COUNT = MessageFormat.format(SQL_COUNT, getTableName());
        SQL_COUNT_EPHEMERAL = MessageFormat.format(SQL_COUNT_EPHEMERAL, getTableNameEphemeral());

        if (jdbcHelper == null) {
            setJdbcHelper(buildJdbcHelper(), true);
        }

        super.init();

        if (jdbcHelper == null) {
            throw new IllegalStateException("JDBC helper is null.");
        }

        return this;
    }
107872
public static String exampleSelectColumns(Class<?> entityClass) {
        StringBuilder sql = new StringBuilder();
        sql.append("<choose>");
        sql.append("<when test=\"@tk.mybatis.mapper.util.OGNL@hasSelectColumns(_parameter)\">");
        sql.append("<foreach collection=\"_parameter.selectColumns\" item=\"selectColumn\" separator=\",\">");
        sql.append("${selectColumn}");
        sql.append("</foreach>");
        sql.append("</when>");
        //不支持指定列的时候查询全部列
        sql.append("<otherwise>");
        sql.append(getAllColumns(entityClass));
        sql.append("</otherwise>");
        sql.append("</choose>");
        return sql.toString();
    }
156601
public static <T> DatabaseTableConfig<T> fromClass(ConnectionSource connectionSource, Class<T> clazz)
			throws SQLException {
		DatabaseType databaseType = connectionSource.getDatabaseType();
		String tableName = DatabaseTableConfig.extractTableName(databaseType, clazz);
		List<DatabaseFieldConfig> fieldConfigs = new ArrayList<DatabaseFieldConfig>();
		for (Class<?> classWalk = clazz; classWalk != null; classWalk = classWalk.getSuperclass()) {
			for (Field field : classWalk.getDeclaredFields()) {
				DatabaseFieldConfig config = configFromField(databaseType, tableName, field);
				if (config != null && config.isPersisted()) {
					fieldConfigs.add(config);
				}
			}
		}
		if (fieldConfigs.size() == 0) {
			return null;
		} else {
			return new DatabaseTableConfig<T>(clazz, tableName, fieldConfigs);
		}
	}
37132
public static String getAllColumns(Class<?> entityClass) {
        Set<EntityColumn> columnSet = EntityHelper.getColumns(entityClass);
        StringBuilder sql = new StringBuilder();
        for (EntityColumn entityColumn : columnSet) {
            sql.append(entityColumn.getColumn()).append(",");
        }
        return sql.substring(0, sql.length() - 1);
    }
922437
public JdbcMapperBuilder<T> addMapping(final String column, final int index, final int sqlType) {
        addMapping(column, index, sqlType, FieldMapperColumnDefinition.<JdbcColumnKey>identity());
        return this;
    }
368616
public static String convertJavaClassToSqlType(String simpleClassName) throws SQLException {
        if ("String".equals(simpleClassName) == true) {
            return "VARCHAR";
        }

        throw new SQLException(String.format("Could not convert java class %s", simpleClassName));
    }
899998
@SuppressWarnings("unchecked")
    public <N extends Object> List<N> findOneColumn(String sql, List<?> params, final int mapperColumnIndex) {

        if (sql == null) {
            recordLog(" param sql is null!");
        }

        // 查询
        return findBySQL(sql, params, new RowMapper<N>() {
            public N mapRow(ResultSet rs, int count) throws SQLException {
                return (N) (rs.getObject(mapperColumnIndex));
            }
        });
    }
776857
private boolean isDate(Class clazz)
    {
        return clazz.isAssignableFrom(Date.class) || clazz.isAssignableFrom(java.sql.Date.class)
                || clazz.isAssignableFrom(Timestamp.class) || clazz.isAssignableFrom(Time.class)
                || clazz.isAssignableFrom(Calendar.class);
    }
337298
@Override
	public Object getObject(final int columnIndex) throws SQLException {
		String columnLabel = getWrapped().getMetaData().getColumnLabel(columnIndex);

		return getObject(columnLabel);
	}
1158913
@Override
    public <E> List<E> getColumnsById(String schemaName, String joinTableName, String joinColumnName,
            String inverseJoinColumnName, Object parentId, Class columnJavaType)
    {
        StringBuffer sqlQuery = new StringBuffer();
        sqlQuery.append("SELECT ").append(inverseJoinColumnName).append(" FROM ")
                .append(getFromClause(schemaName, joinTableName)).append(" WHERE ").append(joinColumnName).append("='")
                .append(parentId).append("'");

        Session s = getSession();

        SQLQuery query = s.createSQLQuery(sqlQuery.toString());

        List<E> foreignKeys = new ArrayList<E>();

        foreignKeys = query.list();

        return foreignKeys;
    }
404363
static Cl map(ResultSet rs, int colShift)
    {
        Cl tmp = new Cl();

        try
        {
            tmp.id = rs.getInt(1 + colShift);
            tmp.name = rs.getString(2 + colShift);
            tmp.childFirst = rs.getBoolean(3 + colShift);
            tmp.hiddenClasses = rs.getString(4 + colShift);
            tmp.tracingEnabled = rs.getBoolean(5 + colShift);
            tmp.persistent = rs.getBoolean(6 + colShift);
            tmp.allowedRunners = rs.getString(7 + colShift);
        }
        catch (SQLException e)
        {
            throw new DatabaseException(e);
        }
        return tmp;
    }
485125
public static String selectAllColumns(Class<?> entityClass) {
        StringBuilder sql = new StringBuilder();
        sql.append("SELECT ");
        sql.append(getAllColumns(entityClass));
        sql.append(" ");
        return sql.toString();
    }
628534
public void setJdbc(java.util.Collection<CodeGenNodeArg> jdbc) {
        if (jdbc == null) {
            this.jdbc = null;
            return;
        }

        this.jdbc = new java.util.ArrayList<CodeGenNodeArg>(jdbc);
    }
146558
protected SqlForClass getSqlForClass(ClassDescriptor cld)
    {
        SqlForClass result = (SqlForClass) sqlForClass.get(cld);
        if(result == null)
        {
            result = newInstanceSqlForClass();
            sqlForClass.put(cld, result);
        }
        return result;
    }
1214550
protected final Class<ID> getIdClass() {

		@SuppressWarnings("unchecked")
		final Class<ID> result = (Class<ID>) TypeHelper.getTypeArguments(JpaSearchRepository.class, this.getClass()).get(1);
		return result;
	}
908113
@Override
  public Map<String, JdbcType> retrieveDateColumns(String database, String table)
      throws SQLException {
    Map<String, JdbcType> targetDataTypes =
        ImmutableMap.<String, JdbcType>builder().put("DATE", JdbcType.DATE).put("TIME WITH TIME ZONE", JdbcType.TIME)
            .put("TIME WITHOUT TIME ZONE", JdbcType.TIME).put("TIMESTAMP WITH TIME ZONE", JdbcType.TIMESTAMP)
            .put("TIMESTAMP WITHOUT TIME ZONE", JdbcType.TIMESTAMP).build();

    ImmutableMap.Builder<String, JdbcType> dateColumnsBuilder = ImmutableMap.builder();

    try (PreparedStatement pstmt = this.conn
        .prepareStatement(INFORMATION_SCHEMA_SELECT_SQL_PSTMT, ResultSet.TYPE_SCROLL_INSENSITIVE,
            ResultSet.CONCUR_READ_ONLY)) {
      pstmt.setString(1, database);
      pstmt.setString(2, table);
      log.info("Retrieving column type information from SQL: " + pstmt);
      try (ResultSet rs = pstmt.executeQuery()) {
        if (!rs.first()) {
          throw new IllegalArgumentException("No result from information_schema.columns");
        }
        do {
          String type = rs.getString("data_type").toUpperCase();
          JdbcType convertedType = targetDataTypes.get(type);
          if (convertedType != null) {
            dateColumnsBuilder.put(rs.getString("column_name"), convertedType);
          }
        } while (rs.next());
      }
    }
    return dateColumnsBuilder.build();
  }