JPA ObjectOptimisticLockingFailureException on an Insert sql execution followed by an Update sql execution
I'm using Spring-data-jpa with Kotlin and I faced this error:
org.springframework.orm.ObjectOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed
Here is my parent entity (unnecessary parts are omitted):
@Entity
class Parent(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long = 0L,
@OneToMany(mappedBy = "parent", cascade = [CascadeType.ALL], orphanRemoval = true)
val...