我正在 eclipse 中开发 spring 4.0
和 hibernate 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/