Hello. It`s small, but very confusing bug. I have 1 entity class with PK. In code i create new entity, but not save it to database (my bug). After that i make some entity changes and try to update it. I think entity already saved, but not. Hibernate generate update query with "where id=null" and PgSQL return 0 updated rows. By this condition, Hibernate throws:
javax.persistence.OptimisticLockException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Exception class very confusing, I some time search reason of lock. Only after deep debugging i found wrong update query with id=null. |