Several reasons are there for this issue :
Why ?
IDENTITY ID generator with a table column which is not properly configured. It should be an auto_increment column for the IDENTITY generator to work. Else, the database doesn't return any generated ID.
How to solve?
1) And fixing this is as simple as making sure that the Primary Key Column, of the table you are working with, has Auto Increment set.
2) In such scenario, you not need to create table manually. It will create by default using hibernate. make change or add in hibernate.cfg.xml >> "hibernate.hbm2ddl.auto" field set to "update".
3) We must
auto_increment
the id
column of the table by using below query ALTER TABLE document MODIFY COLUMN document_id INT auto_increment