The exception:
org.hibernate.AssertionFailure: null id in entry (don’t flush the Session after an exception occurs)
Tells us that the session exception has happened before the point where this org.hibernate.AssertionFailure
is thrown.
To be exact, the org.hibernate.AssertionFailure
is thrown when the session.flush()
is happening, not the point where the error ocurred.
The above is a fact, thus a possible conclusion from it is: something could be suppressing the original exception.
So look for other possible points of error: A save()
or saveOrUpdate()
is possibly trying to persist an entity with a null
field where, in the table, the column is NOT NULL
?
TIP:
To help in the debugging, try adding a session.flush()
after every interaction with the Session
object (e.g. session.save(obj)
, session.merge(obj)
, etc.), this will hopefully cause the org.hibernate.AssertionFailure
to happen earlier, closer to where the real problem is taking place. (Of course, after the debugging, remove those session.flush()
.)
In my case, the **real** exception was taking place inside a `try/catch {}` block where the `catch` suppressed the exception (didn’t rethrow or warn me about it).