Spring JPA / Hibernate transaction force insert instead of update

后端 未结 3 1397
小蘑菇
小蘑菇 2021-01-04 11:13

Edited. Whilst extending the base repository class and adding an insert method would work an more elegant solution appears to be implementing Persistable in the entities.

3条回答
  •  旧时难觅i
    2021-01-04 12:05

    Why not create a clone object which clones everything except your primary keys and then save this cloned object.

    Since the PK will not be present, an insert happens, instead of an update

提交回复
热议问题