The stacktrace you posted is not the same that originated IdentifierGenerationException
. The stacktrace posted means that someone is locking a database table to which your transaction wants to write.
If this is a development database, most probably it's a SQL GUI client like My SQL workbench that has a transaction opened that is not yet committed. It can also a process that you thought you killed that is still around.
To troubleshoot this, kill all java processes and then with MySql workbench or equivalent, see if there are any processes connected to the database. If you have administrator rights in the database you also kill the sessions manually, this will release the locks.
For the IdentifierGenerationException
problem, you need to do:
page.setAtom(atom);
atom.setPage(page);
The reason for this is that the foreign key generator in one-to-one relations takes they key from one entity and uses the same value as the key for the other entity, as one table primary key is also a foreign key to the other table.
In this case the property atom.setPage()
was null, and hibernate was trying to copy the key from Page to Atom, but atom.getPage()
was null, causing the error message you posted. See also this answer and this tutorial.