How to refresh JPA entities when backend database changes asynchronously?

后端 未结 4 862
情深已故
情深已故 2020-12-07 09:08

I have a PostgreSQL 8.4 database with some tables and views which are essentially joins on some of the tables. I used NetBeans 7.2 (as described here) to create REST based

4条回答
  •  攒了一身酷
    2020-12-07 09:52

    Just a thought, but how do you receive your EntityManager/Session/whatever?

    If you queried the entity in one session, it will be detached in the next one and you will have to merge it back into the persistence context to get it managed again.

    Trying to work with detached entities may result in those not-managed exceptions, you should re-query the entity or you could try it with merge (or similar methods).

提交回复
热议问题