1、主要语句
判断sql 语句:
select
CONCAT('<if test="',
-- 驼峰
CONCAT(
SUBSTRING_INDEX(LOWER(column_name),'_',1),
substr(UPPER(column_name),
length(SUBSTRING_INDEX(column_name,'_',1)) + 2,1),
substr(LOWER(column_name),
length(SUBSTRING_INDEX(column_name,'_',1)) + 3,
length(SUBSTRING_INDEX(column_name,'_',2)) - length(SUBSTRING_INDEX(column_name,'_',1))-2),
substr(UPPER(column_name),
length(SUBSTRING_INDEX(column_name,'_',2)) + 2,1),
substr(LOWER(column_name),
length(SUBSTRING_INDEX(column_name,'_',2)) + 3,
length(SUBSTRING_INDEX(column_name,'_',3)) - length(SUBSTRING_INDEX(column_name,'_',2))-2)
),-- 驼峰
'!= null ">',
column_name,
'= #{',
CONCAT(
SUBSTRING_INDEX(LOWER(column_name),'_',1),
substr(UPPER(column_name),
length(SUBSTRING_INDEX(column_name,'_',1)) + 2,1),
substr(LOWER(column_name),
length(SUBSTRING_INDEX(column_name,'_',1)) + 3,
length(SUBSTRING_INDEX(column_name,'_',2)) - length(SUBSTRING_INDEX(column_name,'_',1))-2),
substr(UPPER(column_name),
length(SUBSTRING_INDEX(column_name,'_',2)) + 2,1),
substr(LOWER(column_name),
length(SUBSTRING_INDEX(column_name,'_',2)) + 3,
length(SUBSTRING_INDEX(column_name,'_',3)) - length(SUBSTRING_INDEX(column_name,'_',2))-2)
),-- 驼峰
',jdbcType=',
-- data_type,
if(data_type='int','INTEGER',if(data_type='datetime','DATE','VARCHAR')),'</if>'
)
'判断语句'
from information_schema.columns
where table_name='activity_participation_list' and table_schema='hehashopdbvrun';
执行后如图:
适合开启了驼峰的mybatis 注解
,此方法不如mybatis的逆向工程舒服