异常信息:

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异常的更多相关文章

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

    在有关联关系的数据表中保存数据时,先保存一端,再保存多端的抛出的异常(此时不管一端,还是多端的对象都没有设置id,属性,也就是要保存的两个对象的id 属性为空.) org.hibernate.id.I ...

  2. 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 ...

  3. org.hibernate.id.IdentifierGenerationException

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

  4. 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 ...

  5. org.hibernate.id.IdentifierGenerationException错误解决方法

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

  6. 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 ...

  7. 错误/异常:org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save() 的解决方法

    1.错误/异常视图 错误/异常描述:id的生成错误,在调用save()方法之前,必须先生成id. 2.解决方法     在对应的实体类的主键(id)的get方法上加上:@GeneratedValue( ...

  8. 报错: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());

  9. hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常

    用hibernate进行映射查询时,出现Caused by: java.sql.SQLException: Column 'id' not found 异常,检查数据库表及映射都有id且已经正确映射, ...

随机推荐

  1. [python 学习] requests 库的使用

    1.get请求 # -*- coding: utf-8 -*- import requests URL_IP = "http://b.com/index.php" pyload = ...

  2. bzoj4543 [POI2014]Hotel加强版 长链剖分+树形DP

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=4543 题解 这道题的弱化版 bzoj3522 [POI2014]Hotel 的做法有好几种吧. ...

  3. Spring的AOP和IoC及隔离级别

    Spring的AOP和IoC Spring AOP:代理机制.Spring提供的自动代理机制 Spring的IoC来实组件之间的依赖关系注入, 使控制层与业务实现分离,即客户通过调用业务委托接口来调用 ...

  4. VS TODO注释快捷键

    快速按出任务列表 todo 注释 Ctrl 键+ \| 键+ T键

  5. windows下zookeeper集群安装

    windows下zookeeper单机版安装,见:https://www.cnblogs.com/lbky/p/9867899.html 一:zookeeper节点为什么是奇数个? 单机模式的zk进程 ...

  6. macaca搭建

    对于新鲜的事务总是那么好奇,在自动化的过程中,有幸了解到macaca,记录下安装过程,具体介绍请移步官网:https://github.com/macacajs/ python版本参考:https:/ ...

  7. Spring MVC (二)

    一.使用 @RequestMapping 映射请求 Spring MVC使用@RequestMapping注解为控制器指定可以处理哪些URL请求 在控制器的类定义以及方法定义处都可以标注 类定义处:提 ...

  8. 【leetcode】403. Frog Jump

    题目如下: 解题思路:我的做法是建立一个字典dic,key为stone,value是一个set,里面存的是从前面的所有stone跳跃到当前stone的unit集合.例如stones=[0,1,2,3] ...

  9. MaxCompute按量计费计算任务消费监控告警

    MaxCompute 按量计费资源为弹性伸缩资源,对于计算任务,按任务需求提供所需资源,对资源使用无限制,同时MaxCompute按量计费的账单为天账单,即当天消费需要第二天才出账,因此,有必要对计算 ...

  10. AI 一体机,满足新时代的新需求

    AI 变革带来哪些 IT 的新要求? 深度学习的突破和硬件的突飞猛进,使得人工智能“第n春”焕发蓬勃生机.这是历史上第一次,机器可以在如人脸识别等‘人类’工作上做得比我们人类更好. 人工神经网络有许多 ...