代码拉取完成,页面将自动刷新
在mybatis-generator-core基础上作了改进,更符合自己的实际需求
取消了生成的实体类中属性的get/set方法,增加了Lombok插件的@Data注解;
<!-- 增加对Lombok插件的支持 -->
<plugin type="org.mybatis.generator.plugins.LombokPlugin">
</plugin>
<table tableName="tb_user" domainObjectName="User" enableInsertSelective="false" enableUpdateByPrimaryKey="false">
<!-- 增加对查询条件的支持 -->
<conditionColumn columns="username,name,age"/>
</table>
Mapper.xml文件中生成where条件的statement
<sql id="queryConditions">
<where>
<if test="username != null and username != ''">
and username = #{username,jdbcType=VARCHAR}
</if>
<if test="name != null and name != ''">
and name = #{name,jdbcType=VARCHAR}
</if>
<if test="age != null ">
and age = #{age,jdbcType=INTEGER}
</if>
</where>
</sql>
生成的2组查询片段
<select id="selectListByForm" parameterType="cn.fetosoft.test.form.UserForm" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_user
<include refid="queryConditions"></include>
<!-- 此处增加的是对分页的支持,可根据需要自行处理 -->
<include refid="base.orderAndPage"></include>
</select>
<select id="selectCountByForm" parameterType="cn.fetosoft.test.form.UserForm" resultType="java.lang.Integer">
select count(id) as c
from tb_user
<include refid="queryConditions"></include>
</select>
<!-- 配置生成查询类Form -->
<javaFormGenerator targetPackage="cn.fetosoft.test.form"
targetProject="D:/git/mybatis-generator/src/main/java" />
selectByPrimaryKey
selectListByForm
selectCountByForm
deleteByPrimaryKey
insert
updateByPrimaryKeySelective
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。