org.hibernate.id.IdentifierGenerationException: Hibernate异常
异常信息:
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.geore.pojo.linkman.LinkMan
at org.hibernate.id.Assigned.generate(Assigned.java:34)
上面的异常信息显示在com.geore.pojo.linkman.LinkMan中的id值,在save()方法调用之前,必须手动的输入。那么造成这个的原因可能就是在Hibernate的实体类的xml的配置中对于主键的生成策略没有配置。因此有可能导致出现这样的问题。
出错代码:
<id name="lid" column="lid"></id>
正确配置:
<id name="lid" column="lid">
<generator class="uuid"></generator>
</id>
所以解决的方案就是在Hibernate的实体类的配置文件中给出主键的生成策略(如上)或者另一种解决的办法,主键不通过Hibernate生成,由自己给出,如下:
linkman.setLid(UUID.randomUUID().toString().replace("-", ""));
org.hibernate.id.IdentifierGenerationException: Hibernate异常的更多相关文章
- 异常:org.hibernate.id.IdentifierGenerationException
在有关联关系的数据表中保存数据时,先保存一端,再保存多端的抛出的异常(此时不管一端,还是多端的对象都没有设置id,属性,也就是要保存的两个对象的id 属性为空.) org.hibernate.id.I ...
- org.hibernate.id.IdentifierGenerationException: Unknown integral data type for ids : java.lang.String
org.hibernate.id.IdentifierGenerationException: Unknown integral data type for ids : java.lang.Strin ...
- org.hibernate.id.IdentifierGenerationException
[问题]org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned bef ...
- 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 ...
- org.hibernate.id.IdentifierGenerationException错误解决方法
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before ...
- Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.qingmu.seller.entity.OrderMaster
org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before ...
- 错误/异常:org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save() 的解决方法
1.错误/异常视图 错误/异常描述:id的生成错误,在调用save()方法之前,必须先生成id. 2.解决方法 在对应的实体类的主键(id)的get方法上加上:@GeneratedValue( ...
- 报错:Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): cn.itcast.bos.domain.base.SubArea
因为 实体类中的主键 是String类型 不能自动为其分配id 所以需要手动设置在service层 model.setId(UUID.randomUUID().toString());
- hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常
用hibernate进行映射查询时,出现Caused by: java.sql.SQLException: Column 'id' not found 异常,检查数据库表及映射都有id且已经正确映射, ...
随机推荐
- Mysql8- Public Key Retrieval is not allowed
在使用 MySQL 8.0 时重启应用后提示 com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public ...
- 【推荐系统】知乎live入门3.召回
参考链接 [推荐系统]知乎live入门 目录 1. 概述 2. 画像过滤 3. 协同过滤 4. 内容过滤 5. 模型过滤 6. 其他过滤 7. 总结 ========================= ...
- VMware新加网卡NAT连接(内网)出现本机与虚拟机ping不通的问题
今新加网卡NAT连接,配置好之后始终出现eth1:link is not ready. 虚拟机与本机不能建立连接. 解决方案:windows里面打开服务开启VMware NAT Service,并关闭 ...
- 阿里P8技术栈
- 【LeetCode】二分 binary_search(共58题)
[4]Median of Two Sorted Arrays [29]Divide Two Integers [33]Search in Rotated Sorted Array [34]Find F ...
- 在Node.js环境下使用Express创建Web项目实例
序:如果你还不知道Node.js是什么,那么你可以先看看这篇:Node.js 究竟是什么?或者任何关于它的介绍. 一.安装Node.js 1.进入Node.js官网下载并安装 2.启动cmd输入命令查 ...
- 关于pug的笔记
一.简介 Pug 是一款健壮.灵活.功能丰富的模板引擎,专门为 Node.js 平台开发.Pug 是由 Jade 改名而来,他可以帮助我们写html的时候更加的简单明了.安装.使用pug的过程打开cm ...
- hive之wordcount
1.创建一张表,记录文件数据,使用换行符作为分隔符 create table file_data(content string) row format delimited fields termina ...
- Python---基础---水仙花数和三色球
一.编写一个程序,求100~999之间的所有水仙花数 如果一个3位数等于其各位数字的立方和,则称这个数为水仙花数.例如:153 = 1^3 + 5^3 + 3^3,因此153就是一个水仙花数 for ...
- tuple拆包操作
""" tuple 是不可变对象 """ user_tuple = ('admin', 18, "cd", " ...