异常信息:

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. 媒介查询demo

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. Maven中添加Jetty服务器配置

    <project> <!--其它配置--> <build> <plugins> <plugin> <groupId>org.mo ...

  3. hdu 4082 Hou Yi's secret(暴力枚举)

    Hou Yi's secret Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. Ubuntu16.04 重新安装误删的某个*.so文件

    在使用Ubuntu系统时,如果不小心将某个*.so文件删除,该如何重新安装呢? 如果直接使用命令:sudo  apt-get  install  *.so 可能会报错或者找不到这个*.so文件. 正确 ...

  5. neo4j传参

    py2neo_graph= py2neo.Graph("http://****", user="****", password="*****" ...

  6. C# 与 C++,语法差别有多小-第三章 C++数据类型 第一部分

    一,数据类型 C++: char  int short  long float double, unsigned long double(128位,19位有效数字), wchar_t, 浮点型文字常量 ...

  7. 2017 ICPC HongKong B:Black and White(扫描线+线段树)

    题目描述 Consider a square map with N × N cells. We indicate the coordinate of a cell by (i, j), where 1 ...

  8. B/S大文件断点续传

    一. 功能性需求与非功能性需求 要求操作便利,一次选择多个文件和文件夹进行上传:支持PC端全平台操作系统,Windows,Linux,Mac 支持文件和文件夹的批量下载,断点续传.刷新页面后继续传输. ...

  9. POJ 2502 Subway ( 最短路 && 最短路建图 )

    题意 : 给出二维平面上的两个点代表起点以及终点,接下来给出若干条地铁线路,除了在地铁线路上行进的速度为 40km/h 其余的点到点间都只能用过步行且其速度为 10km/h ,现问你从起点到终点的最短 ...

  10. Android中对Apk加固(加壳)续篇之---对Native层(so文件)进行加固

    有人说Android程序用Java代码写的,再怎么弄都是不安全的,很容易破解的,现在晚上关于应用加固的技术也很多了,当然这些也可以用于商业发展的,梆梆加密和爱加密就是很好的例子,当然这两家加固的Apk ...