Mybatis SelectKey 问题

.Net技术 码拜 9年前 (2015-05-10) 1699次浏览 0个评论

我写好了selectkey。
语句如下

 <selectKey property=”Id” type=”post” resultClass=”int”>
        ${selectKey}
      </selectKey>

我想要在handler里面使用这个值。应该怎么使用。。新人求解。才接触

${selectKey}?
虽然我好长时间没用ibatis了,但你这个貌似不对啊,这东西接受的是sql参数,而不是一句完整的sql
至于handler里面怎么用,你直接看下ibatis的ido部分就知道了啊
算了。我把我写在XML的整个语句全写出来吧。。很基础的东西,就是怎么在handler里面使用这个selectkey

    <!–添加–>
    <insert id=”Insert” parameterClass=”Hashtable”>
      <selectKey property=”Id” type=”post” resultClass=”int”>
        ${selectKey}
      </selectKey>
      insert into Sys_Grades(GradeName,Education,Description)
      values(#GradeName#,#Education#,#Description#)
    </insert>

引用 1 楼 starfd 的回复:

${selectKey}?
虽然我好长时间没用ibatis了,但你这个貌似不对啊,这东西接受的是sql参数,而不是一句完整的sql
至于handler里面怎么用,你直接看下ibatis的ido部分就知道了啊

大神帮我看看,基础的东西不知道怎么办了- –

扔了这垃圾ibatis吧,这玩意在开发的时候就为了一个SQL语句就这么头大,在以后维护的时候更有头疼的事情
40分
原来SelectKey是这东西啊……
http://blog.csdn.net/starfd/article/details/43482263
对应Insert方法,ibatis的Insert本身就是会有返回值的

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Mybatis SelectKey 问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!