org.hibernate.id.IdentifierGenerationException错误解决方法

发布于 2011-10-02 | 更新于 2020-09-20

Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()

因为ID设置为了手动设置:

而在保存时没有设置ID:

privilegeGroupService.save(group);

导致出现这个错误。

在保存时可以手动设置个UUID即可:

public void save(PrivilegeGroup entity) {
entity.setGroupid(UUID.randomUUID().toString());
super.save(entity);
}

本文作者: arthinking

本文链接: https://www.itzhai.comorg-hibernate-id-identifiergenerationexception-error-solution.html

版权声明: 版权归作者所有,未经许可不得转载,侵权必究!联系作者请加公众号。

×
IT宅

关注公众号及时获取网站内容更新。