CeccoCQ
CeccoCQ

Reputation: 3754

Java JPA - Sync Database and Entity

I'm using JPA for my Enterprise Application, and when I change values of row into my database table the related entity (get it by a find(-)) isn't updated with new value.

I think that there is a problem of sync between entity and database or a simple cache, so, how can I solve it?

Upvotes: 2

Views: 3707

Answers (1)

Piotr Nowicki
Piotr Nowicki

Reputation: 18174

If you edit the database row not using the JPA you should invoke EntityManager#refresh(-) using the entity fetched by find(-) as a parameter or invoke EntityManager#clear(-) and then invoke the find(-) again.

Upvotes: 2

Related Questions