mybatis常⽤jdbcType数据类型
1
BIT FLOAT CHAR TIMESTAMP OTHER UNDEFINED
TINYINT REAL VARCHAR BINARY BLOB NVARCHAR
SMALLINT DOUBLE LONGVARCHAR VARBINARY CLOB NCHAR
INTEGER NUMERIC DATE LONGVARBINARY BOOLEAN NCLOB
BIGINT DECIMAL TIME NULL CURSOR
<resultMap type="java.util.Map" id="resultjcm">
<result property="FLD_NUMBER" column="FLD_NUMBER" javaType="double" jdbcType="NUMERIC"/>
<result property="FLD_VARCHAR" column="FLD_VARCHAR" javaType="string" jdbcType="VARCHAR"/>
<result property="FLD_DATE" column="FLD_DATE" javaType="java.sql.Date" jdbcType="DATE"/>
<result property="FLD_INTEGER" column="FLD_INTEGER" javaType="int" jdbcType="INTEGER"/>
<result property="FLD_DOUBLE" column="FLD_DOUBLE" javaType="double" jdbcType="DOUBLE"/>
<result property="FLD_LONG" column="FLD_LONG" javaType="long" jdbcType="INTEGER"/>
<result property="FLD_CHAR" column="FLD_CHAR" javaType="string" jdbcType="CHAR"/>
<result property="FLD_BLOB" column="FLD_BLOB" javaType="[B" jdbcType="BLOB" />
<result property="FLD_CLOB" column="FLD_CLOB" javaType="string" jdbcType="CLOB"/>
<result property="FLD_FLOAT" column="FLD_FLOAT" javaType="float" jdbcType="FLOAT"/>
<result property="FLD_TIMESTAMP" column="FLD_TIMESTAMP" javaType="java.sql.Timestamp" jdbcType="TIMESTAMP"/> </resultMap>
JDBC Type Java Type
CHAR String
VARCHAR String
LONGVARCHAR String
NUMERIC java.math.BigDecimal
DECIMAL java.math.BigDecimal
BIT boolean
BOOLEAN boolean
TINYINT byte
SMALLINT short
INTEGER int
BIGINT long
REAL float
FLOAT double
DOUBLE double
BINARY byte[]
VARBINARY byte[]oracle decimal类型
LONGVARBINARY byte[]
DATE java.sql.Date
TIME java.sql.Time
TIMESTAMP java.sql.Timestamp
CLOB Clob
BLOB Blob
ARRAY Array
DISTINCT mapping of underlying type
STRUCT Struct
REF Ref
DATALINK java.URL[color=red][/color]
⽤mybatis generator⽣成代码后,执⾏查询语句时,oracle⾥的Date类型字段只精确到年⽉⽇,后⾯时分秒都为零。 jdbcType="DATE"时候,存⼊到数据库中的字段只有年⽉⽇!
后来发现是jdbcType问题,改成 jdbcType="TIMESTAMP" 就可以。(原先默认⽣成时是jdbcType="DATE")
地址:
SQL数据类型JDBC类型代码标准的Java类型Oracle扩展的Java类型
1.0标准的JDBC类型:
CHAR java.sql.Types.CHAR java.lang.Strin
g
oracle.sql.CHAR
VARCHAR2java.sql.Types.VARCHAR java.lang.Strin
g
oracle.sql.CHAR
LONG java.sql.Types.LONGVARC
HAR
java.lang.Strin
g
oracle.sql.CHAR
NUMBER java.sql.Types.NUMERIC java.math.Big
Decimal
oracle.sql.NUMBE
R
NUMBER java.sql.Types.DECIMAL java.math.Big
Decimal
oracle.sql.NUMBE
R
NUMBER java.sql.Types.BIT boolean oracle.sql.NUMBE R
NUMBER java.sql.Types.TINYINT byte oracle.sql.NUMBE R
NUMBER java.sql.Types.SMALLINT short oracle.sql.NUMBE
R
NUMBER java.sql.Types.INTEGER int oracle.sql.NUMBE R
NUMBER java.sql.Types.BIGINT long oracle.sql.NUMBE R
NUMBER java.sql.Types.REAL float oracle.sql.NUMBE R
NUMBER java.sql.Types.FLOAT double oracle.sql.NUMBE R
NUMBER java.sql.Types.DOUBLE double oracle.sql.NUMBE R
RAW java.sql.Types.BINARY byte[]oracle.sql.RAW RAW java.sql.Types.VARBINARY byte[]oracle.sql.RAW
LONGRAW java.sql.Types.LONGVARBI
NARY
byte[]oracle.sql.RAW
DATE java.sql.Types.DATE java.sql.Date oracle.sql.DATE DATE java.sql.Types.TIME java.sql.Time oracle.sql.DATE
TIMESTAMP java.sql.Types.TIMESTAMP javal.sql.Times
tamp
oracle.sql.TIMEST
AMP
2.0标准的JDBC类型:
BLOB java.sql.Types.BLOB java.sql.Blob oracle.sql.BLOB CLOB java.sql.Types.CLOB java.sql.Clob oracle.sql.CLOB
⽤户定义的对象java.sql.Types.STRUCT java.sql.Struct oracle.sql.STRUC T
⽤户定义的参考java.sql.Types.REF java.sql.Ref oracle.sql.REF
⽤户定义的集合java.sql.Types.ARRAY java.sql.Array oracle.sql.ARRAY
Oracle扩展:
BFILE oracle.jdbc.OracleTypes.BFI
LE
N/A oracle.sql.BFILE
ROWID oracle.jdbc.OracleTypes.RO
WID
N/A oracle.sql.ROWID
REF CURSOR oracle.jdbc.OracleTypes.CU
RSOR
java.sql.Result
Set
oracle.jdbc.Oracle
ResultSet
TIMESTAMP oracle.jdbc.OracleTypes.TIM
ESTAMP
java.sql.Timest
amp
oracle.sql.TIMEST
AMP
TIMESTAMP WITH TIME ZONE oracle.jdbc.OracleTypes.TIM
ESTAMPTZ
java.sql.Timest
amp
oracle.sql.TIMEST
AMPTZ
TIMESTAMP WITH LOCAL TIME ZONE oracle.jdbc.OracleTypes.TIM
ESTAMPLTZ
java.sql.Timest
amp
oracle.sql.TIMEST
AMPLTZ
SQL数据类型JDBC类型代码标准的Java类型Oracle扩展的Java类型
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论