zoukankan      html  css  js  c++  java
  • Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: java.sql.SQLException: 不支持的特性

    mybatis插入数据时报错:

    Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: java.sql.SQLException: 不支持的特性
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)

    原因:加了如下标红的设置(useGeneratedKeys="true"把新增加的主键赋值到自己定义的keyProperty(id)中)

    <insert id="insert" parameterType="com.vimtech.bms.business.domain.monitor.finan.AssetsVisitReportWithBLOBs" useGeneratedKeys="true" keyProperty="serialid">

    解决方法一:没什么用的话,删除标红的即可;

    解决方法二:用selectKey先查下自增的主键ID值然后赋给相应的主键ID即可

    oracle的写法(查序列的下一个值然后赋值):

    <selectKey resultType="java.lang.Long" order="BEFORE" keyProperty="###">
      SELECT SEQ_ASSETS_VISIT_REPORT.nextval AS ### FROM dual
    </selectKey>

    SQLServer的写法

    <selectKey resultType="java.lang.Integer" keyProperty="timelineConfigId">
      SELECT @@IDENTITY AS TIMELINE_CONFIG_ID
    </selectKey>

  • 相关阅读:
    java和.NET的比较
    联想笔记本不能无线上网
    js根据给定的日期计算当月有多少天
    jQuery中live()变更
    C#操作xml文件
    SQL server的with的用法(一)
    jquery拖拽实现UI设计组件
    自定义弹出框
    第一个超级简单Node.js实例
    windows 下使用redis
  • 原文地址:https://www.cnblogs.com/xh_Blog/p/9858681.html
Copyright © 2011-2022 走看看