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).其实业务还是业务,只 ...
随机推荐
- zookeeper 节点信息
使用get命令获取指定节点的数据时, 同时也将返回该节点的状态信息, 称为Stat. 其包含如下字段: czxid. 节点创建时的zxid. mzxid. 节点最新一次更新发生时的zxid. ctim ...
- Unity3d Attribute 总结
举两个例子,在变量上使用[SerializeFiled]属性,可以强制让变量进行序列化,可以在Unity的Editor上进行赋值. 在Class上使用[RequireComponent]属性,就会在C ...
- Understanding Java 8 Streams API---reference
http://java.amitph.com/2014/01/understanding-java-8-streams-api.html Since past few versions, Java h ...
- swpuctf-web部分学习总结
1.用优惠码 买个 X ? (1)第一步: 这道题第一步主要知道利用php的随机种子数泄露以后就可以利用该种子数来预测序列,而在题目中会返回15位的优惠码,但是必须要24位的优惠码,因此要根据15位的 ...
- C++程序设计基础(5)sizeof的使用
1.知识点 (1)sizeof是一个单目运算发,而不是一个函数,其用于获取操作数所占内存空间的字节数. (2)sizeof的操作数可以使类型名,也可以是表达式,如果是类型名则直接获得该类型所占字节数, ...
- 解决npm install安装慢的问题
国外镜像会很慢 可用 get命令查看registry npm congfig get registry 原版结果为 http://registry.npmjs.org 用set命令换成阿里的镜像就可以 ...
- 浅谈------location
今天在上班的时候碰到了要根据不同的页面随机添加栏目的问题,很简单的问题,想到了判断页面url是否含有某字符串来进行随机添加栏目...这就需要了解location对象. location 属性名 属性说 ...
- sql查询时,根据特定的条件给表的某一个字段赋值
先讲一下需要这个需求的情景: 这是一个招聘求职项目遇到的一个问题.个人A向公司B的职位投递简历后,公司B会收到个人A的简历;但是A投递后把简历删除,公司收到的简历信箱 还有这个简历,但却不能看了. 原 ...
- struts2返回结果类型
在action下还有result标签 1.result不只有name,其实还有type result返回类型在struts-default.xml默认的配置文件中有定义,可以看到有result-typ ...
- Spring课程 Spring入门篇 5-3 配置切入点 pointcut
1 解析 1.1 xml常见的配置切入点写法 2 代码演练 2.1 xml配置切入点 1 解析 1.1 xml常见的配置切入点写法 2 代码演练 2.1 xml配置切入点 xml配置: <? ...