ids for this class must be manually assigned before calling save():
Caused by: javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.cjonline.ship.entity.TBLMyRecents
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:)
at org.jboss.ejb3.entity.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:)
at com.cjonline.ship.dao.base.BaseDaoBean.save(BaseDaoBean.java:)
这个异常比较简单,就是实体类的id在执行save方法时没有赋值。
可以设置主键的策略模式,常见的UUID和自增长,在EJB中如下:
@Id
@GenericGenerator(name = "system-uuid", strategy = "uuid")
@GeneratedValue(generator = "system-uuid")
@Column(length = ,nullable=false)
public String getId() {
return id;
} //-------------------------------------------------// @Id
@GeneratedValue(strategy = GenerationType.AUTO)
public String getId() {
return id;
}
ids for this class must be manually assigned before calling save():的更多相关文章
- 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 ...
- 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 ...
- Hibernate: ids for this class must be manually assigned before calling save():
原文: http://blog.csdn.net/softimes/article/details/7008875 引起问题的原因: 由Hibernate根据数据库表自动生成的"类名.hbm ...
- hibernate save数据的时候报错:ids for this class must be manually assigned before calling save()
这个错误是因为eclipse 这种jpatools 自动生成的实体类内没把id 设置为自增,还有id的值在生成的时候默认为string 即使加上了也所以无法自增 ,所以还需要把string 换成In ...
- 报错: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());
- ids for this class must be manually assigned before calling save():Xxx
把Xxx.hbm.xml主键生成策略改成identity
- 错误/异常:org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save() 的解决方法
1.错误/异常视图 错误/异常描述:id的生成错误,在调用save()方法之前,必须先生成id. 2.解决方法 在对应的实体类的主键(id)的get方法上加上:@GeneratedValue( ...
- assigned before calling save & JPA id生成策略
撸了今年阿里.网易和美团的面试,我有一个重要发现.......>>> Ⅰ 关于JPA 主键,自定义生成遇到的问题,愚蠢的笔记 Ⅱ 第一次 报错: ids for this class ...
- 整合s2sh,实现页面操作数据库
先说点废话 s2sh,就是struts2,spring,hibernate:s2作为表现层和控制器,hibernate作为持久层,spring作为业务层(充分应用IOC和AOP).其实业务还是业务,只 ...
随机推荐
- Django 入门项目案例开发(上)
关注微信公众号:FocusBI 查看更多文章:加QQ群:808774277 获取学习资料和一起探讨问题. Django 入门案例开发(中) http://www.cnblogs.com/focusBI ...
- Codeforces 975D. Ghosts
Description 给出一条直线 \(a*x+b\) 上的 \(n\) 个点,每一个点有一个速度 \((v_x,v_y)\),求 \(T=[-oo,oo]\) 相交的次数乘以 \(2\) 题面 S ...
- 【Iftop】实时监控流量工具
linux基本查询流量的命令有: 1.ifconfig 只能看到当前接收和发送出去的总共的字节大小,但是不能看到网卡流量的实时发送情况 2.watch more /proc/net/dev 只有接受 ...
- C#学习笔记10
1.匿名类型:匿名类型是C#3.0新增的特性,是强类型(由编译器后台在生成为CIL时,自动声明的代码定义类型),声明与初始化属性后其属性是尽读属性.只有在属性的名称.顺序.类型一致时,多个声明匿名变量 ...
- Menu 的key dispatch
DecorView
- IO流之流的操作规律
流的操作规律 IO流中对象很多,解决问题(处理设备上的数据时)到底该用哪个对象呢? 把IO流进行了规律的总结(四个明确): l 明确一:要操作的数据是数据源还是数据目的. 源:InputStream ...
- vue+rest-framework前后端分离整合(二)
一.基于api前端显示课程详细信息 1.调整Course.vue模块 <template> <div> <h1>课程列表</h1> <div v- ...
- PHP正则表达式实例汇总
$str = preg_replace("/(<a.*?>)(.*?)(<\/a>)/", '\1<span class="link&quo ...
- URL工具类
UrlUtils = { /** * 判断url是否存在(存在跨域问题) * @param {String} url */ isTrueUrl: function(_url) { result = f ...
- SpringBoot-mvn插件
在maven projects中有一组springboot的插件 六个选择: 0.build-info:Generate a build-info.properties file based the ...