mybatis使⽤oracle⾃动⽣成主键
下⾯总结了两种⽅式,⼀种是使⽤oracle的sys_guid函数⾃动⽣成,另⼀种是使⽤sequence,
⽅法⼀:
<insert id="insert" useGeneratedKeys="false" keyProperty="storeId" parameterType="zttc.itat.user.po.TStore" >
<selectKey resultType="String" keyProperty="storeId" order="BEFORE">
select sys_guid() from dual
</selectKey>
insert into T_STORE (STORE_ID, STORE_NAME, STORE_PRICE,CREATE_DATE,END_DATE
)
values ( #{storeId,jdbcType=VARCHAR}, #{storeName,jdbcType=VARCHAR}, #{storePrice,jdbcType=DECIMAL}, #{createDate,jdbcType=VARCHAR},#{endDate,jdbcType=VARCH
AR}
)
</insert>
⽅法⼆:
<insert id="insert" parameterType="zttc.itat.user.po.TStore" >
insert into T_STORE (STORE_ID, STORE_NAME, STORE_PRICE,CREATE_DATE,END_DATE
)
values (val, #{storeName,jdbcType=VARCHAR}, #{storePrice,jdbcType=DECIMAL},
#{createDate,jdbcType=VARCHAR},#{endDate,jdbcType=VARCHAR}
)
</insert>
<insert id="insert" useGeneratedKeys="false" keyProperty="storeId" parameterType="zttc.itat.user.po.TStore" >
<selectKey resultType="String" keyProperty="storeId" order="BEFORE">
select val as storeId from dual
</selectKey>
insert into T_STORE (STORE_ID, STORE_NAME, STORE_PRICE,CREATE_DATE,END_DATE
)
values ( #{storeId,jdbcType=VARCHAR}, #{storeName,jdbcType=VARCHAR}, #{storePrice,jdbcType=DECIMAL}, #{createDate,jdbcType=VARCHAR},#{endDate,jdbcType=VARCHAR}
)
</insert>
>oracle decimal类型
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论