JPA thinks I'm deleting a detached object

前端 未结 7 2219
萌比男神i
萌比男神i 2020-12-14 00:30

I\'ve got a DAO that I used to load and save my domain objects using JPA. I finally managed to get the transaction stuff working, now I\'ve got another issue.

In my

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 00:43

    What worked for me was calling flush so the changes are made as in the following example:

    @PersistanceContext
    EntityManager em;
    
    public SomeObject(...parameters){
        repository.save();
        em.flush();
        repository.delete();
    }
    

提交回复
热议问题