根据某个字段（最好是唯一字段）查询单个记录<br>
当有多条返回时，只显示查询到的第一条

@param <T> 字段值类型
@param field 字段名
@param value 字段值
@return 记录
@throws SQLException SQL执行异常
514672
public <T> Entity get(String field, T value) throws SQLException {
		return this.get(Entity.create(tableName).set(field, value));
	}
957711
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static void setFieldValue(Object bean, String fieldNameOrIndex, Object value) {
		if (bean instanceof Map) {
			((Map) bean).put(fieldNameOrIndex, value);
		} else if (bean instanceof List) {
			CollUtil.setOrAppend((List) bean, Convert.toInt(fieldNameOrIndex), value);
		} else if (ArrayUtil.isArray(bean)) {
			ArrayUtil.setOrAppend(bean, Convert.toInt(fieldNameOrIndex), value);
		} else {
			// 普通Bean对象
			ReflectUtil.setFieldValue(bean, fieldNameOrIndex, value);
		}
	}
1200130
public Where<T, ID> eq(String columnName, Object value) throws SQLException {
		addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
				SimpleComparison.EQUAL_TO_OPERATION));
		return this;
	}
1020813
public static Query withStringIgnoreCase(String field, String value) {
        return Query.withString(field, value, true);
    }
1274703
public static Object convertSqlXml(Object sqlXml, String value) throws SQLException {
        return convertSqlXml(sqlXml, value.getBytes());
    }
244607
public function getRecord($tableName, $field, $value, $fields = array())
    {
        try {
            return $this->db->getRecord($tableName, $field, $value, $fields);
        } catch (\Exception $e) {
            throw new DbException($e->getMessage());
        }
    }
232967
public static java.sql.Time toTime(Object value) throws ParseException {
        if (value == null) {
            return null;
        }
        if (value instanceof java.sql.Time) {
            return (java.sql.Time) value;
        }
        if (value instanceof String) {
            if ("".equals((String) value)) {
                return null;
            }
            return new java.sql.Time(IN_TIME_FORMAT.parse((String) value).getTime());
        }

        return new java.sql.Time(IN_TIME_FORMAT.parse(value.toString()).getTime());
    }
363797
public <T> T resultToJava(DatabaseResults results, Map<String, Integer> columnPositions) throws SQLException {
		Integer dbColumnPos = columnPositions.get(columnName);
		if (dbColumnPos == null) {
			dbColumnPos = results.findColumn(columnName);
			columnPositions.put(columnName, dbColumnPos);
		}

		/*
		 * Subtle problem here. If the field is a foreign-field and/or a primitive and the value was null then we get 0
		 * from results.getInt() which mirrors the ResultSet. We have to specifically test to see if we have a null
		 * result with results.wasNull(...) afterwards so we return a null value to not create the sub-object or turn a
		 * Integer field into 0 instead of null.
		 * 
		 * But this presents a limitation. Sometimes people want to convert a result field value that is stored in the
		 * database as null into a non-null value when it comes out of the database. There is no way to do that because
		 * of the results.wasNull(...) checks after the fact then override the non-null value from the converter.
		 */
		@SuppressWarnings("unchecked")
		T converted = (T) fieldConverter.resultToJava(this, results, dbColumnPos);
		if (fieldConfig.isForeign()) {
			/*
			 * If your foreign field is a primitive and the value was null then this would return 0 from
			 * results.getInt(). We have to specifically test to see if we have a foreign field so if it is null we
			 * return a null value to not create the sub-object.
			 */
			if (results.wasNull(dbColumnPos)) {
				return null;
			}
		} else if (dataPersister.isPrimitive()) {
			if (fieldConfig.isThrowIfNull() && results.wasNull(dbColumnPos)) {
				throw new SQLException(
						"Results value for primitive field '" + field.getName() + "' was an invalid null value");
			}
		} else if (!fieldConverter.isStreamType() && results.wasNull(dbColumnPos)) {
			// we can't check if we have a null if this is a stream type
			return null;
		}
		return converted;
	}
770826
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;
	}
292351
public boolean set(String field, String value) {
		boolean result = false;
		if(value == null)return false;
		//返回值（1:新字段被设置,0:已经存在值被更新）
		try {
			result = getJedisCommands(groupName).hset(key, field, value) >= 0;
			//设置超时时间
			if(result)setExpireIfNot(expireTime);
			return result;
		} finally {
			getJedisProvider(groupName).release();
		}
	}
859730
@SuppressWarnings("unchecked")
    public static <T> List<T> getValueOfCertainColumnOfAllRecord(String sql, Object... arg) {
        Connection connection = JDBCUtils.getConnection();
        PreparedStatement ps = null;

        ResultSet result = null;
        List<T> list = new ArrayList<T>();// 存放查询到的记录的字段的值
        try {
            ps = connection.prepareStatement(sql);
            // 填充占位符
            for (int i = 0; i < arg.length; i++) {
                ps.setObject(i + 1, arg[i]);
            }
            // 获取结果集
            result = ps.executeQuery();
            // 循环遍历结果集中的记录，并将每条记录的第一个字段放入List中
            while (result.next()) {
                list.add((T) result.getObject(1));
            }

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {

            JDBCUtils.release(result, ps, connection);
        }

        return list;
    }
575801
private function FieldCondition($field, $value)
        {
            $tbl = $this->Table();
            $mapper = $this->FieldMapper($field);
            $dbVal = $mapper->ToDBString($value);
            
            $sql = $this->SqlBuilder();
            
            if ($dbVal === null)
                return $sql->IsNull($tbl->Field($field));
            else
                return $sql->Equals($tbl->Field($field), $sql->Value($dbVal));
        }
684463
public static void throwSQLException(Exception cause, String theType, String value)
            throws SQLException {
        throw new SQLException("Invalid " + theType + " value: " + value, cause);
    }
1013748
public List<Map<String, Object>> selectList(String sql, Object value) {
        Class<?> parameterType = value != null ? value.getClass() : null;
        String msId = msUtils.selectDynamic(sql, parameterType);
        return sqlSession.selectList(msId, value);
    }
1164898
@SuppressWarnings("unchecked")
    public static <T extends Object> T getFieldValue(Object obj, Field field) {
        Assert.notNull(obj, "obj不能为空");
        Assert.notNull(field, "field不能为空");

        try {
            return (T) field.get(obj);
        } catch (IllegalArgumentException e) {
            throw new ReflectException(e);
        } catch (IllegalAccessException e) {
            String msg = StringUtils.format("类型[{0}]的字段[{1}]不允许访问", obj.getClass(),
                field.getName());
            log.error(msg);
            throw new ReflectException(msg, e);
        }
    }
465122
void setValue(int parameterIndex, PreparedStatement preparedStatement,
			Class<?> fieldType, Object fieldValue) throws Exception {

		try {

			if (fieldType == String.class) {
				preparedStatement
						.setString(parameterIndex, (String) fieldValue);
			} else if (fieldType == java.sql.Timestamp.class) {
				preparedStatement.setTimestamp(parameterIndex,
						(java.sql.Timestamp) fieldValue);
			} else if (fieldType == java.sql.Date.class) {
				preparedStatement.setDate(parameterIndex,
						(java.sql.Date) fieldValue);
			} else if (fieldType == java.sql.Time.class) {
				preparedStatement.setTime(parameterIndex,
						(java.sql.Time) fieldValue);
			} else if (fieldType == boolean.class || fieldType == Boolean.class) {

				if (fieldValue != null) {
					boolean boolValue = (boolean) (Boolean) fieldValue;
					preparedStatement.setInt(parameterIndex,
							(boolValue ? 1 : 0));
				} else {
					preparedStatement.setInt(parameterIndex, 0);

				}
			} else if (fieldType == int.class || fieldType == Integer.class) {

				if (fieldValue != null) {
					preparedStatement.setInt(parameterIndex,
							(int) (Integer) fieldValue);
				} else {
					preparedStatement.setNull(parameterIndex,
							java.sql.Types.INTEGER);
				}
			} else if (fieldType == long.class || fieldType == Long.class) {

				if (fieldValue != null) {
					preparedStatement.setLong(parameterIndex,
							(long) (Long) fieldValue);
				} else {
					preparedStatement.setNull(parameterIndex,
							java.sql.Types.INTEGER);
				}
			} else if (fieldType == float.class || fieldType == Float.class) {

				if (fieldValue != null) {
					preparedStatement.setFloat(parameterIndex,
							(float) (Float) fieldValue);
				} else {
					preparedStatement.setNull(parameterIndex,
							java.sql.Types.FLOAT);
				}

			} else if (fieldType == double.class || fieldType == Double.class) {

				if (fieldValue != null) {
					preparedStatement.setDouble(parameterIndex,
							(double) (Double) fieldValue);
				} else {
					preparedStatement.setNull(parameterIndex,
							java.sql.Types.DOUBLE);
				}

			} else {
				final String msg = "Unknown data type. type=" + fieldType
						+ " value=" + fieldValue;
				loge(msg);
				throw new RuntimeException(msg);
			}
		} catch (Exception e) {
			loge("#setValue", e);
			throw e;
		}

	}
881546
public function where($field, $table, $value) {
        static $i = 0;
        $sql = self::resolve_field($field, $table) . ' ';

        if ($value === null) {
            $sql .= 'IS NULL';

        } else {
            $param = 'where' . $i++;
            $sql .= " = :$param";
            $this->params[$param] = $value;
        }

        $this->where[] = $sql;
    }