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():的更多相关文章

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

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

  3. Hibernate: ids for this class must be manually assigned before calling save():

    原文: http://blog.csdn.net/softimes/article/details/7008875 引起问题的原因: 由Hibernate根据数据库表自动生成的"类名.hbm ...

  4. hibernate save数据的时候报错:ids for this class must be manually assigned before calling save()

    这个错误是因为eclipse  这种jpatools 自动生成的实体类内没把id 设置为自增,还有id的值在生成的时候默认为string 即使加上了也所以无法自增 ,所以还需要把string 换成In ...

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

  6. ids for this class must be manually assigned before calling save():Xxx

    把Xxx.hbm.xml主键生成策略改成identity

  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. assigned before calling save & JPA id生成策略

    撸了今年阿里.网易和美团的面试,我有一个重要发现.......>>> Ⅰ 关于JPA 主键,自定义生成遇到的问题,愚蠢的笔记 Ⅱ 第一次 报错: ids for this class ...

  9. 整合s2sh,实现页面操作数据库

    先说点废话 s2sh,就是struts2,spring,hibernate:s2作为表现层和控制器,hibernate作为持久层,spring作为业务层(充分应用IOC和AOP).其实业务还是业务,只 ...

随机推荐

  1. mongodb连接失败原因排查

    安装了mongodb,添加了管理员root和test数据库的用户rex,并且开启的用户认证. 按照说明文档连接mongodb数据库:$mongo = new Mongo("mongodb:/ ...

  2. 使用pygame开发一个弹幕射击游戏(一)

    本文作为开发过程记录用. 目前游戏画面: 下一个添加的功能:敌机可以进行射击. 弹幕类 from pygame.sprite import Sprite from pygame import tran ...

  3. nginx 导致文件上传中途中断 Failed to load resource: net::ERR_CONNECTION_RESET

    昨天上传文件出了问题,常常在进度条到一半的时候就终止了.在本地测试的时候倒是没问题,今天早上用花生壳换了另一个域名,在我本地和服务器都测试,却能够上传文件成功.然后就想到了可能是nginx的问题,也在 ...

  4. 51nod 1245 Binomial Coefficients Revenge

    Description C(M,N) = M! / N! / (M - N)! (组合数).给出M和质数p,求C(M,0), C(M,1)......C(M,M)这M + 1个数中,有多少数不是p的倍 ...

  5. 移动端H5页面注意事项

    1. 单个页面内容不能过多 设计常用尺寸:7501334 / 6401134,包含了手机顶部信号栏的高度. 移动端H5活动页面常常需要能够分享到各种社交App中,常用的有微信.QQ等. 使用移动设备查 ...

  6. JS常用的设计模式(2)——简单工厂模式

    简单工厂模式是由一个方法来决定到底要创建哪个类的实例, 而这些实例经常都拥有相同的接口. 这种模式主要用在所实例化的类型在编译期并不能确定, 而是在执行期决定的情况. 说的通俗点,就像公司茶水间的饮料 ...

  7. 【设计模式】template method(模板方法)-- 类行为型模式5.10

    1.意图 子类在不改变父类的算法结构的情况下,可以重定义算法的某些特定步骤 2.动机 模板方法用一些抽象的操作定义一个算法,子类重定义这些操作以提供具体的行为:步骤的顺序定了,但实现可以调整: 3.适 ...

  8. 常用DOM结构方法总结

    ---内容开始--- 获取元素的方法: getElementById() 通过ID名获取元素 getElementsByTagName() 通过元素(标签)名称 getElementsByClassN ...

  9. Highcharts - Bar Chart & Column Chart

    1. 条形图(Bar Chart)需要的数据格式类型如下: ["Luke Skywalker", "Darth Vader", "Yoda" ...

  10. stopPropagation()阻止事件向父容器传递

    topPropagation()函数用于阻止当前事件在DOM树上冒泡. 根据DOM事件流机制,在元素上触发的大多数事件都会冒泡传递到该元素的所有祖辈元素上,如果这些祖辈元素上也绑定了相应的事件处理函数 ...