Why use returned instance after save() on Spring Data JPA Repository?

前端 未结 2 1469
夕颜
夕颜 2020-12-02 13:14

Here is the code:

@Repository
public interface AccountRepository extends JpaRepository {}

JpaRepository from

2条回答
  •  离开以前
    2020-12-02 13:38

    You missed the second part: if the entity isn't new, merge is called. merge copies the state of its argument into the attached entity with the same ID, and returns the attached entity. If the entity isn't new, and you don't use the returned entity, you'll make modifications to a detached entity.

提交回复
热议问题