Skip to content

ccdaisy/mybatis-generator-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mybatis-generator-mysql

mysql plugin for mybatis-generator. mvn prj.

mybatis的自动生成一直都是常用且高效的dao生成方式,自动化就必然会使得出错少、并且易管理。可是很多时候,不同数据库有其不同的语句特征,比如mysql的自增主键的获取、mysql的分页和其它数据库都有所不同,因此加了两个plugin来辅助mybatis-generator生成代码。

主要功能:

InsertSelectKeyPlugin:

<selectKey keyProperty="iID" resultType="int" order="AFTER">
select LAST_INSERT_ID()
</selectKey>

生成固定的mysql返回插入数据的当前自增键

PaginationPlugin:

生成select的固定limit语句,同时在example增加limit功能。

觉得mysql还有不少可以使用的plugin,如逻辑删除等等,有时间完善再加。

SelectForUpdatePlugin:

生成select的固定selectForUpdate语句,可以在example中设置wait 的时间。

使用时千万注意,对不根据主键查询会加表级锁,切记加上主键

觉得mysql还有不少可以使用的plugin,如逻辑删除等等,有时间完善再加。

使用方法:

###1.加入此工程的dependencies到maven的plugin element。 org.mybatis.generator mybatis-generator-maven-plugin
1.3.2 true true com.fit-time.utils mybatis-generator-pagination 0.0.1-SNAPSHOT ###2.编辑generatorConfig.xml ... ... ###3.mvn mybatis-generator:generate ###4.check result and enjoy

About

mysql plugin for mybatis-generator. mvn prj.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages