java.lang.IllegalArgumentException: Removing a detached instance com.test.User#5

前端 未结 5 1735
执笔经年
执笔经年 2020-12-07 16:32

I have a java EE project using JPA (transaction-type=\"JTA\"), hibernate as provider. I write my beans to handle the CRUD things. The program running in JBOSS 7 AS.

5条回答
  •  Happy的楠姐
    2020-12-07 17:09

    In my experience, if I query an object from the DB then closed the entity manager then do a DB delete, the problem happens. Or if I copy that loaded object to another instance then do a delete, this problem also happens. In my opinion there are 2 things to keep note:

    • The object must be in the same session that was created by the Entity Manager
    • And the object mustn't be transferred to another object while the Entity Manager's session is still opened.

    Cheers

提交回复
热议问题