Javatype and Jdbctype types correspond in MyBatis

Source: Internet
Author: User

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

Type conversion table between Mysql/jdbc/java

MySQL data type jdbc Type (getcolumntypename) Java type returned by default (Getcolumnclassname)
BIT (1) (New in MySQL-5.0) BIT Java.lang.Boolean
BIT (> 1) (New in MySQL-5.0) BIT Byte[]
TINYINT TINYINT Java.lang.Boolean if the configuration property tinyint1isbit are set to True (the default) and the storage size is 1, or J Ava.lang.Integer if not.
BOOL, BOOLEAN TINYINT TINYINT, above as are aliases for TINYINT (1), currently.
smallint[(M)] [UNSIGNED] SMALLINT [UNSIGNED] Java.lang.Integer (regardless of whether it is UNSIGNED or not)
mediumint[(M)] [UNSIGNED] Mediumint [UNSIGNED] Java.lang.Integer (regardless of whether it is UNSIGNED or not)
int,integer[(M)] [UNSIGNED] INTEGER [UNSIGNED] Java.lang.Integer, if UNSIGNED java.lang.Long
bigint[(M)] [UNSIGNED] BIGINT [UNSIGNED] Java.lang.Long, if UNSIGNED Java.math.BigInteger
float[(M,D)] FLOAT Java.lang.Float
double[(M,B)] DOUBLE Java.lang.Double
decimal[(M[,d])] DECIMAL Java.math.BigDecimal
DATE DATE Java.sql.Date
Datetime Datetime Java.sql.Timestamp
timestamp[(M)] TIMESTAMP Java.sql.Timestamp
Time Time Java.sql.Time
year[(2|4)] Year If yearisdatetype configuration is set to False, then the returned object type is Java.sql.Short. If set to True (the default), then the returned object was of type Java.sql.Datewith the date set to January 1st, at Midnig Ht.
CHAR (M) CHAR Java.lang.String (unless the character set for the ' column is BINARY, then byte[] is returned.
VARCHAR (M) [BINARY] VARCHAR Java.lang.String (unless the character set for the ' column is BINARY, then byte[] is returned.
BINARY (M) BINARY Byte[]
VARBINARY (M) VARBINARY Byte[]
Tinyblob Tinyblob Byte[]
Tinytext VARCHAR Java.lang.String
Blob Blob Byte[]
TEXT VARCHAR Java.lang.String
Mediumblob Mediumblob Byte[]
Mediumtext VARCHAR Java.lang.String
Longblob Longblob Byte[]
Longtext VARCHAR Java.lang.String
ENUM (' value1 ', ' value2 ',...) CHAR Java.lang.String
SET (' value1 ', ' value2 ',...) CHAR Java.lang.String

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.