Class TypedUUIDHandler
- All Implemented Interfaces:
org.apache.ibatis.type.TypeHandler<Object>
@MappedJdbcTypes({VARCHAR,BINARY,OTHER})
@MappedTypes(java.util.UUID.class)
public class TypedUUIDHandler
extends org.apache.ibatis.type.BaseTypeHandler<Object>
兼容型 UUID TypeHandler:
- Java 写入:支持 UUID / CharSequence(含 String) / byte[16]
- DB 列:支持 VARCHAR / BINARY(16) / OTHER
- 读取:返回 UUID(仅绑定到 UUID 属性上,不绑定 String)
使用建议: 1) 实体字段用 UUID:本 Handler 生效(推荐)。 2) 实体字段用 String:不要让本 Handler 绑定到 String;直接走默认 StringTypeHandler 即可。
- Author:
- lang
-
Field Summary
Fields inherited from class org.apache.ibatis.type.BaseTypeHandler
configuration -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNullableResult(CallableStatement cs, int columnIndex) getNullableResult(ResultSet rs, int columnIndex) getNullableResult(ResultSet rs, String columnName) voidsetNonNullParameter(PreparedStatement ps, int i, Object parameter, org.apache.ibatis.type.JdbcType jdbcType) voidsetParameter(PreparedStatement ps, int i, Object parameter, org.apache.ibatis.type.JdbcType jdbcType) Methods inherited from class org.apache.ibatis.type.BaseTypeHandler
getResult, getResult, getResult, setConfigurationMethods inherited from class org.apache.ibatis.type.TypeReference
getRawType, toString
-
Constructor Details
-
TypedUUIDHandler
public TypedUUIDHandler()
-
-
Method Details
-
setNonNullParameter
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, org.apache.ibatis.type.JdbcType jdbcType) throws SQLException - Specified by:
setNonNullParameterin classorg.apache.ibatis.type.BaseTypeHandler<Object>- Throws:
SQLException
-
setParameter
public void setParameter(PreparedStatement ps, int i, Object parameter, org.apache.ibatis.type.JdbcType jdbcType) throws SQLException - Specified by:
setParameterin interfaceorg.apache.ibatis.type.TypeHandler<Object>- Overrides:
setParameterin classorg.apache.ibatis.type.BaseTypeHandler<Object>- Throws:
SQLException
-
getNullableResult
- Specified by:
getNullableResultin classorg.apache.ibatis.type.BaseTypeHandler<Object>- Throws:
SQLException
-
getNullableResult
- Specified by:
getNullableResultin classorg.apache.ibatis.type.BaseTypeHandler<Object>- Throws:
SQLException
-
getNullableResult
- Specified by:
getNullableResultin classorg.apache.ibatis.type.BaseTypeHandler<Object>- Throws:
SQLException
-