DB change not reflected in collection

View: New views
2 Messages — Rating Filter:   Alert me  

DB change not reflected in collection

by measwel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

LS,

I have a User entity that holds a collection of Favorite entities. When I add a favorite or remove a favorite in the db (via the favorite entities jpa controller) then I do not see this change reflected in the User's collection of Favorites, even though the fetch type is set to EAGER of the collection. Can somebody explain me what I am doing wrong?

Thank you,
MPK

Re: DB change not reflected in collection

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You must always update both sides of the relationship,

See,
http://en.wikibooks.org/wiki/Java_Persistence/Relationships#Object_corruption.2C_one_side_of_the_relationship_is_not_updated_after_updating_the_other_side

Your JPA provider is probably also caching, so you may desire to turn off the cache, or call refresh().