Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

针对BIGINT UNSIGNED类型字段,生成的Mapper文件jdbcType错误 #319

Open
sagexueqi opened this issue Jul 5, 2021 · 0 comments
Open

Comments

@sagexueqi
Copy link
Contributor

问题描述
在mysql数据库中,表中字段类型为bigint(20) unsigned时,生成的Mapper文件jdbcType=BIGINT UNSIGNED。导致应用加载Mapper配置失败,无法启动。

  • 建表语句
    image

  • GUI中显示的JDBC TYPE
    image

  • Mapper文件中错误的jdbcType
    image

期望结果
针对类似的字段数据类型,需要根据java.sql.Types转换为实际的jdbcType。

bigint(20) unsigned在mapper中的jdbcType应该为BIGINT

问题原因

  • 加载定制列数据时,通过DbUtil.getTableColumns()获取列JDBC TYPE的过程中,直接根据rs.getString("TYPE_NAME")获取到的Type名称作为JDBC TYPE,并覆盖mybatis-generator生成的列配置

修复方案

  • DbUtil.getTableColumns()设置字段jdbc type时,使用mybatis generator提供的JavaTypeResolverDefaultImpl进行转换
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant