save method - doesn't flush the Session after an exception occurs
From the error:
org.hibernate.AssertionFailure
:null id
inmodels.Software
entry (don't flush theSession
after an exception occurs)
We can see that a session exception has happened before. The point where this org.hibernate.AssertionFailure
is thrown is not the point where the error ocurred.
That is: Something is 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
.
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).
the issue seems to be that Hibernate raises an exception (so the current transaction gets invalidated) but then you are trying to proceed with more operations in that session.
The proper way to do this would be to split the test you are using in 2, one part to test null authors and one to test with a valid author.
On production code (let's say a controller), you would need to restart the operation (close the transaction, relaunch the process) to be able to proceed. But given the way play manages transactions, the normal behavior would be that after the error you would just return with an error message to the user.
Maybe someone would repeat my mistake:
I also come across with this problem. In my case the problem had occured because I set column
type integer
, and tried to wrote long
value. After changing column
type it start to work.