org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():

ID主键生成策略为assigned 由应用程序负责生成主键标识符

<id name="id" type="java.lang.String">
<column name="ID" length="32" />
<generator class="assigned" />
</id>

而在保存时没有设置ID

session.save(entity);

导致出现此错误

解决方法:

1、在保存时手动设置个ID就可以:

entity.setId(UUID.randomUUID().toString());
session.save(entity);

2、改动主键生成策略为其它

作者:itmyhome

org.hibernate.id.IdentifierGenerationException错误解决方法的更多相关文章

  1. org.hibernate.id.IdentifierGenerationException: Hibernate异常

    异常信息: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned b ...

  2. C#常见错误解决方法

    1.能提供Visual Studio开发工具包吗? 解决方法: Visual Studio 2017开发环境下载地址: https://www.visualstudio.com/zh-hans/dow ...

  3. org.hibernate.id.IdentifierGenerationException

    [问题]org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned bef ...

  4. Linux遇到的问题(一)Ubuntu报“xxx is not in the sudoers file.This incident will be reported” 错误解决方法

    提示错误信息 www@iZ236j3sofdZ:~$ ifconfig Command 'ifconfig' is available in '/sbin/ifconfig' The command ...

  5. org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()

    org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before ...

  6. SQL SERVER 9003错误解决方法 只适用于SQL2000

    SQLSERVER 9003错误解决方法 只适用于SQL2000 (只适用于SQL2000) "无法打开新数据库 'POS'.CREATE DATABASE 中止. (Microsoft S ...

  7. New XAMPP security concept:错误解决方法

    New XAMPP security concept:错误解决方法 (2014-03-06 16:07:46) 转载▼   分类: php 在Linux上配置xampp后远程访问域名报错: New X ...

  8. hadoop本地库与系统版本不一致引起的错误解决方法

    hadoop本地库与系统版本不一致引起的错误解决方法 部署hadoop的集群环境为 操作系统 centos 5.8 hadoop版本为cloudera   hadoop-0.20.2-cdh3u3 集 ...

  9. mysql Access denied for user root@localhost错误解决方法总结(转)

    mysql Access denied for user root@localhost错误解决方法总结(转) mysql Access denied for user \'root\'@\'local ...

随机推荐

  1. 【Luogu】P2324骑士精神(IDA*)

    题目链接 当guess>limit-deep的时候return就好了. guess是估价函数,值为不在自己地盘上的骑士个数.limit是本次迭代阈值.deep是已经走了多少步. 这个优化是显然的 ...

  2. HDU——1045Fire Net(最大匹配)

    Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total S ...

  3. BestCoder Round #29 1003 (hdu 5172) GTY's gay friends [线段树 判不同 预处理 好题]

    传送门 GTY's gay friends Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  4. shell按日期自动切割nginx日志脚本

    shell按日期自动切割nginx日志脚本 参考:自学it网 http://www.zixue.it/. #nginx日志切割脚本 #author:ce #!/bin/bash #设置日志文件存放目录 ...

  5. vcenter api 接口获取开发

    通过连接vcenter 管理服务器,获取其下所有的:存储,网络,ESXI实体机,虚拟机相关信息的脚步: #!/opt/python3/bin/python3 #Author: zhaoyong &qu ...

  6. 真的了解CDN服务吗?

    Im CDN,WOW,COOL CDN知识详解 全称:Content Delivery Network或Content Ddistribute Network,即内容分发网络,CDN是构建在网络之上的 ...

  7. Easy sssp(spfa)(负环)

    vijos    1053    Easy sssp 方法:用spfa判断是否存在负环 描述 输入数据给出一个有N(2 <= N <= 1,000)个节点,M(M <= 100,00 ...

  8. json常见用法-loads、jumps、load、jump

    这一篇博客的目的主要是想说明一个问题:干什么事情要抓住重点,不要力求完美,不要追求那种'大而全'的办事方式,因为时间是有限的,而客观事物(这里主要指技术方面的知识)是无限的,so,anyway! 1. ...

  9. [Bzoj3205][Apio2013]机器人(斯坦纳树)(bfs)

    3205: [Apio2013]机器人 Time Limit: 15 Sec  Memory Limit: 128 MBSubmit: 977  Solved: 230[Submit][Status] ...

  10. 《深入理解mybatis原理》 MyBatis的一级缓存实现详解 及使用注意事项

    MyBatis是一个简单,小巧但功能非常强大的ORM开源框架,它的功能强大也体现在它的缓存机制上.MyBatis提供了一级缓存.二级缓存 这两个缓存机制,能够很好地处理和维护缓存,以提高系统的性能.本 ...