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且已经正确映射, ...
随机推荐
- C++多态下的访问修饰符
C++多态下的访问修饰符 先上代码: class Parent { public: virtual void showMsg() { cout << "Parent showMs ...
- JDK 8 中Stream流中的去重的方法
JDK 8 中Stream流中去重的方法 1.简单的去重,可以使用distinct()方法去重,该方法是通过比较equals和hashcode值去去重, 2.复杂的去重, 例如,在一个JavaBean ...
- C# ASP.NET发送电子邮件System.Net.Mail
1.补充知识 (1)POP3和SMTP服务器是什么? 简单点来说:POP3 用于接收电子邮件 ,SMTP 用于发送电子邮件. (1)POP3具体指什么? POP3(Post Office Protoc ...
- python中的垃圾回收机制及原理
序言: 来一起看看: 不同于C/C++,像Python这样的语言是不需要程序员写代码来管理内存的,它的GC(Garbage Collection)机制 实现了自动内存管理.GC做的事情就是解放程序员的 ...
- C++宽字符串转字符串
这文章是更改别人代码 #include <string> #include <iostream> #include <stdlib.h> #include < ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - D
题目链接:http://codeforces.com/contest/831/problem/D 题意:在一个一维坐标里,有n个人,k把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终 ...
- [POJ3694]Network(Tarjan,LCA)
[POJ3694]Network Description A network administrator manages a large network. The network consists o ...
- (转)nginx+redis实现接入层高性能缓存技术
转自:https://blog.csdn.net/phil_code/article/details/79154271 1. OpenRestyOpenResty是一个基于 Nginx与 Lua的高性 ...
- git clone的低级错误
犯了一个低级错误: server ip: 192.168.40.41 有一个git账户 所有的git仓库都在/home/git仓库下 比如/home/git/u-boot-2018.07-fmxx.g ...
- linux环境进程开机自检脚本
Linux下shell脚本监控Tomcat的状态并实现自动启动 最近公司需要在Linux下监控tomcat的服务,一旦tomcat服务存在异常或者宕机,重启tomcat保证服务的正常运行,由于Linu ...