欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

MyBatis常用的jdbcType数据类型

程序员文章站 2024-03-11 10:53:49
mybatis 通过包含的jdbctype类型 bit float char timestamp other undefined...

mybatis 通过包含的jdbctype类型

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

mybatis中javatype和jdbctype对应和crud例子

<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> 

mybatis中javatype和jdbctype对应关系

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[] 
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.net.url[color=red][/color]

以上所述是小编给大家介绍的mybatis常用的jdbctype数据类型,希望对大家有所帮助