使用Oracle的序列號(hào)
先查詢出下一個(gè)序列號(hào),且會(huì)自動(dòng)注入到參數(shù)中的指定屬性上(本例中的id屬性), 插入完成后, controller中的user對(duì)象的id屬性也有值了
<insert id="addUser" parameterType="user" > <!-- keyPRoperty: 將序列號(hào)設(shè)置到user對(duì)象中,且在controller中可以使用 --> <selectKey keyProperty="id" order="BEFORE" resultType="string"> SELECT seq_changez_user.nextval id from dual </selectKey> insert into temp_changez_user (id, username) values(#{id}, #{username}) </insert>
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注