java - 组织.hibernate.id.IdentifierGenerationException : ids for this class must be manually assigned before calling save(): while id is autogenerate in oracle

标签 java eclipse spring oracle hibernate

我正在 eclipse 中开发 spring 4.0hibernate 4.0.1 项目,并使用 oracle 作为数据库。如果我在数据库中进行一些更改,那么更改将不会受到 eclipse 的影响。例如。我在 oracle 中生成 id 此代码在 eclipse 中成功执行。但在那之后我再次对数据库进行了一些更改,相同的代码没有运行它给我错误

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

请帮我解决这个问题。

最佳答案

您的异常的含义是id 没有正确设置。错误在您的映射中。如果您使用sequence 来递增 id,您还必须在映射。请尝试以下操作:

@GeneratedValue(generator = "yourSequenceName", strategy=GenerationType.SEQUENCE)
private int id;

希望对您有所帮助。

关于java - 组织.hibernate.id.IdentifierGenerationException : ids for this class must be manually assigned before calling save(): while id is autogenerate in oracle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30236605/

相关文章:

java - 如何在不使用 Java 将图像加载到内存的情况下裁剪图像

java - 使用 Maven 构建时 JasperReports 找不到字体

java - 数据和大小更改后如何刷新表模型

java - 如何基于使用批注在REST中创建资源的用户授权特定资源

Java Collections.sort() 排除字符范围

java - Spring Boot资源静态文件夹

java - appengine 数据核增强器问题,类未得到增强

java - 如何监控我的 JVM 或 Eclipse 中有多少线程和内存使用情况?

java - 日志记录在 Spring Boot (Gradle) 中不起作用

spring - persistence.xml - spring JPA