How can you replicate Hibernate's saveOrUpdate in JPA?

前端 未结 2 674
时光取名叫无心
时光取名叫无心 2020-12-24 01:25

In JPA, is there any way you can replicate Hibernate\'s saveOrUpdate behavior,

saveOrUpdate

public void saveOrUpdate(Object object)
                  throws         


        
2条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 01:54

    Try using the EntityManager.merge method - this is very similar.

    There is an excellent description of the differences in Xebia's blogpost: "JPA Implementation Patterns: Saving (Detached) Entities."

提交回复
热议问题