mybatis selectkey 返回主键对象异常 求解决 在线等
<insert id="insert" parameterType="Org"><selectKey resultType="String" keyProperty="orgid" order="BEFORE">
SELECT to_char(SEQ_ORG_ID.NEXTVAL) as orgid FROM DUAL
</selectKey>
insert into T_ORG(
ORGID
<if test="name != null">
,NAME
</if>
<if test="nature != -1">
,NATURE
</if>
<if test="contacts != null">
,CONTACTS
</if>
<if test="phone != null">
,PHONE
</if>
<if test="address != null">
,ADDRESS
</if>
<if test="postcode != null">
,POSTCODE
</if>
<if test="email != null">
</if>
,REGTIME
,YXBZ
<if test="bz != null">
,BZ
</if>
) values(
#{id}
<if test="name != null">
,#{name}
</if>
<if test="nature != -1">
,#{nature}
</if>
<if test="contacts != null">
,#{contacts}
</if>
<if test="phone != null">
,#{phone}
</if>
<if test="address != null">
,#{address}
</if>
<if test="postcode != null">
,#{postcode}
</if>
<if test="email != null">
,#{email}
</if>
,SYSDATE
,#{yxbz}
<if test="bz != null">
,#{bz}
</if>
)
</insert>
Org 对象中有属性和方法
private String orgid;
public String getOrgid() {
return orgid;
}
public void setOrgid(String orgid) {
this.orgid = orgid;
}
报错:
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
### The error may exist in mapper/meta/org.xml
### The error may involve com.scm.entity.meta.Org.insert!selectKey-Inline
### The error occurred while setting parameters
### SQL: SELECT to_char(SEQ_ORG_ID.NEXTVAL) as orgid FROM DUAL
### Cause: org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: java.lang.IndexOutOfBoundsException: Index:
0, Size: 0
执行select语句无异常,在设置返回值orgid的时候异常,求解决方案 java mybatis selectkey --------------------编程问答-------------------- 高手何在,求解 --------------------编程问答-------------------- 你这是数组越界了啊 --------------------编程问答-------------------- 为什么会数组越界,都是按照正规路程配置的,是不是不应该引用mybatis-spring 应该引用mybaits ???
--------------------编程问答-------------------- 什么情况,就这么沉了
--------------------编程问答-------------------- Error selecting key or setting result to parameter object.
还是你的主见有问题,建议从这个地方查下你的配置文件。
补充:Java , Java相关