问答详情
源自:5-2 配置去掉Hibernate的配置文件-Spring整合Hibernate

事物保存不了

ERROR - Exception occurred during processing request: ids for this class must be manually assigned before calling save(): cn.czq.entity.Product; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): cn.czq.entity.Product

org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save(): cn.czq.entity.Product; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): cn.czq.entity.Product

at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:690)

一直这个问题好恼火啊


提问者:s四川成都陈 2016-11-13 11:18

个回答

  • 锵锵枪掌柜
    2016-11-21 14:14:49
    已采纳

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

    说你的id必须要设置了才能执行存储。

    应该是在Product.hbm.xml里面看一下pid下面配了<generator class="native"></generator>或者是increment什么的生成器没。

  • s四川成都陈
    2016-11-24 01:01:21

    方法中参数不对引起的