Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand JdbcType Mapping in MyBatis

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to understand the JdbcType mapping in MyBatis". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and study and learn "how to understand the JdbcType mapping in MyBatis" together!

Java projects involve database interaction, which used to be JDBC, but now has Hibernate, Mybatis and other persistence support.

MyBatis is used in the project. The most significant difference between MyBatis and JDBC is that SQL statements are configured. SQL statements are defined through xml files. Of course, JDBC can also configure SQL, requiring custom development. MyBatis directly supports this method.

Official introduction to MyBatis,

MyBatis is a first class persistence framework with support for custom SQL, stored procedures and advanced mappings. MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results. MyBatis can use simple XML or Annotations for configuration and map primitives, Map interfaces and Java POJOs (Plain Old Java Objects) to database records.

Simply put, MyBatis shields almost all JDBC code, and database interaction can be accomplished with a simple xml, or annotation.

xml configuration file, available MyBatis self-defined data type, quoted from: www.mybatis.org/mybatis-3/configuration.html

Associated JDBC type can be specified by two means:

Adding a jdbcType attribute to the typeHandler element (for example: jdbcType="VARCHAR").

Adding a @MappedJdbcTypes annotation to your TypeHandler class specifying the list of JDBC types to associate it with. This annotation will be ignored if the jdbcType attribute as also been specified.

For example, the following configuration specifies that the companyid parameter type is BIGINT,

select a.meetingno

from xxx a

where a.companyid = #{companyid, jdbcType=BIGINT}

For jdbcType, MyBatis API documentation has instructions, quoted from: www.mybatis.org/mybatis-3/apidocs/reference/org/apache/ibatis/type/JdbcType.html

In addition, this article, gives the mapping relationship between JdbcType and Oracle and MySQL, more detailed, quoted from: blog.csdn.net/loongshawn/article/details/50496460

JdbcTypeOracleMySqlJdbcTypeARRAY

JdbcTypeBIGINT

BIGINTJdbcTypeBINARY

JdbcTypeBIT

BITJdbcTypeBLOBBLOBBLOBJdbcTypeBOOLEAN

JdbcTypeCHARJdbcTypeCLOBCLOB modified to TEXTJdbcTypeCURSOR

JdbcTypeDATEDATEDATEJdbcTypeDECIMALDECIMALDECIMALJdbcTypeDOUBLENUMBERDOUBLEJdbcTypeFLOATFLOATFLOATJdbcTypeINTEGERINTEGERINTEGERJdbcTypeLONGVARBINARY

JdbcTypeLONGVARCHARLONG VARCHAR

JdbcTypeNCHARNCHAR

JdbcTypeNCLOBNCLOB

JdbcTypeNULL

JdbcTypeNUMERICNUMERIC/NUMBERNUMERIC/JdbcTypeNVARCHAR

JdbcTypeOTHER

JdbcTypeREALREALREALJdbcTypeSMALLINTSMALLINTSMALLINTJdbcTypeSTRUCT

JdbcTypeTIME

TIMEJdbcTypeTIMESTAMPTIMESTAMPTIMESTAMP/DATETIMEJdbcTypeTINYINT

TINYINTJdbcTypeUNDEFINED

JdbcTypeVARBINARY

JdbcTypeVARCHARVARCHAR Thank you for reading, the above is "how to understand the JdbcType mapping in MyBatis" content, after learning this article, I believe we have a deeper understanding of how to understand the JdbcType mapping in MyBatis, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report