Org.hibernate.id.IdentifierGenerationException: IDs for this class must be assigned manually before calling save (): while id is autogenerated in oracle

I am working on a project spring 4.0

and hibernate 4.0.1

in eclipse and using oracle as a database. If I make some changes to the database, the changes don't affect eclipse. For example. I am generating id in oracle, this code runs successfully in eclipse. But after that I do some changes in the database again, the same code doesn't work, it gives me an error like

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

      

Please help me to solve this problem.

+3


source to share


1 answer


The value of your id exception is not configured correctly . There is an error in your mapping. If you are using sequence

to increase the id, you must do so when matching as well. Try the following:

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

      



Hope this helps you.

+1


source







All Articles