zoukankan      html  css  js  c++  java
  • MySql MyBatis 自动生成主键返回null

    <insert id="insert" parameterType="cn.zno.smse.pojo.UserScan" useGeneratedKeys="true" keyProperty="scanId">

    无法返回自动生成的ID,

    解决:

    数据库中设计表,中勾选自动递增。

    mysql

        <table tableName="usertest" domainObjectName="Usertest" schema="root" delimitAllColumns="true">
        <generatedKey column="user_id" sqlStatement="MySql" identity="true" />
        <columnRenamingRule searchString="user_id" replaceString="id"/></table>

    注: identity 设置为 true 是自增后将 id值放入bean ,设置为false 是先检索 id 值再插入table (oracle 是序列,设置成false,mysql 是自增,设置成true)

  • 相关阅读:
    C++ 的查漏补缺
    Model元数据解析
    Controller
    路由
    win8系统 Reflect 破解
    MVC运行原理
    源代码Log
    linq 分类
    EF 实体关系
    第二十六章 计算限制的异步操作
  • 原文地址:https://www.cnblogs.com/zno2/p/5016896.html
Copyright © 2011-2022 走看看