Mybatis - Mapper文件简练

<!-- 插入一条语句,根据类中存在的数据进行动态解析生成SQL -->
<select id="select" resultMap="BaseResultMap" parameterType="com.metarnet.Execution.DAO.Model.CeicsExecution">
select
<include refid="Base_Column_List" />
from CEICS_EXECUTION
<trim prefix="WHERE" prefixOverrides="AND">
<if test="executionId != null">
AND EXECUTION_ID=#{executionId,jdbcType=DECIMAL}
</if>
<if test="executionName != null" >
AND EXECUTION_NAME like #{executionName,jdbcType=VARCHAR}
</if>
<if test="executionActive != null" >
AND EXECUTION_ACTIVE like #{executionActive,jdbcType=DECIMAL}
</if>
<if test="regDate != null" >
AND REG_DATE=#{regDate,jdbcType=TIMESTAMP}
</if>
</trim>
</select>


<!-- 自动主键(此时的自动主键可在JAVA中获取到) -->
<insert id="insert" parameterType="com.metarnet.Execution.DAO.Model.CeicsExecution" >
<selectKey keyProperty="executionId" resultType="java.math.BigDecimal" order="BEFORE" >
SELECT nvl(max(EXECUTION_ID),0)+1 as executionId FROM CEICS_EXECUTION
</selectKey>
insert into CEICS_EXECUTION (EXECUTION_ID, EXECUTION_NAME, EXECUTION_ACTIVE,
REG_DATE)
values (#{executionId,jdbcType=DECIMAL}, #{executionName,jdbcType=VARCHAR}, #{executionActive,jdbcType=DECIMAL},
#{regDate,jdbcType=TIMESTAMP})

</insert>


-----------------------------------程序员 闫帆原创---------------------------------------

转载请注明原创人信息 程序员 闫帆yanfanvip


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值