2015-05-14 37 views
3

我正在使用eclipse中的spring 4.0hibernate 4.0.1项目并使用oracle作为数据库。如果我在数据库中做了一些更改,那么eclipse不会影响更改。例如。我在oracle中生成id这段代码在eclipse中成功执行。但之后,我再次作出一些更改数据库相同的代码不运行它给我错误org.hibernate.id.IdentifierGenerationException:在调用save()之前必须手动分配这个类的id:while id在oracle中自动生成

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

请帮我解决这个问题。

+0

你如何增加ID? –

+0

incerement id通过在oracle中生成序列号 –

+0

请发布您的映射 –

回答

1

你的异常的含义是ID没有设置好的正确 .The错误是在你的mapping.If您正在使用sequence递增ID也必须为此在mapping.Try如下:

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

我希望这会帮助你。

相关问题