I have a java project that runs on a webserver. I always hit this exception.
I read some documentation, and found that pessimistic locking (or optimistic, but I read
First check your imports, when you use session, transaction it should be org.hibernate
and remove @Transactinal
annotation. and most important in Entity class if you have used @GeneratedValue(strategy=GenerationType.AUTO)
or any other then at the time of model object creation/entity object creation should not create id.
final conclusion is if you want pass id filed i.e PK then remove @GeneratedValue
from entity class.