シーケンスからnextvalを取得してinsert文の主キーにあてようとしています。
■シーケンス
CREATE SEQUENCE SEQ_USER_ID INCREMENT 1 MINVALUE 10000001 MAXVALUE 19999999 START 10000001;
■xml
<insert id="insertAccount">
<selectKey keyProperty="userId" resultType="int">
SELECT NEXTVAL('seq_user_id')
</selectKey>
insert into t_user (user_id, account, password)
values (#{userId}, #{account}, #{password})
</insert>
実際に動かしてみるとselectKeyのkeyPropertyが効かずBindingExceptionが発生してしまいます。
■出力される例外
org.apache.ibatis.binding.BindingException: Parameter 'userId' not found. Available parameters are [password, param3, account, param1, email, param2]
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。