mybatis selectkey 返回主键对象异常 求解决 在线等

wode_java 2013-10-27 05:28:25
<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">
,EMAIL
</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的时候异常,求解决方案
...全文
1978 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuweisyyc 2013-10-27
  • 打赏
  • 举报
回复
Error selecting key or setting result to parameter object. 还是你的主见有问题,建议从这个地方查下你的配置文件。
wode_java 2013-10-27
  • 打赏
  • 举报
回复
什么情况,就这么沉了
wode_java 2013-10-27
  • 打赏
  • 举报
回复
为什么会数组越界,都是按照正规路程配置的,是不是不应该引用mybatis-spring 应该引用mybaits ???
teemai 2013-10-27
  • 打赏
  • 举报
回复
你这是数组越界了啊
wode_java 2013-10-27
  • 打赏
  • 举报
回复
高手何在,求解

51,396

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧