• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Toplink refresh ManyToMany

 
Dan Wisnosky
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a new JSF/JPA application that already has some production users using basic functionality as we develop. We've yet to get a lot of the administration functionality written, and are currently updating user tables and the like with direct SQL queries. I'm having trouble getting Toplink to refresh some of our data when we change it on the back-end.

I have User and Campaign entities in a ManyToMany relationship. When we add or subtract Campaigns to a User, the change is not being reflected if Toplink already has the Campaign collection for that User cached.

On the User entity I have:

And my code for getting the campaign collection is:

I thought that between the refresh hint, the cascande hint, and the REFRESH cascading on the collection, toplink would refresh the collection, but it doesn't seem to be. Anyone have any ideas of what I'm missing?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you are changing the object directly on the database, not through JPA, the object should be up to date and not need to be refreshed. If it is a bi-directional m-m ensure you add/remove from both sides of the relationship.

If you refresh the object you should see the updated database value (check the SQL log to see if it refreshed).

What version of TopLink are you using? If using EclipseLink the query hint is "eclipselink.refresh". Maybe try the refresh() EntityManager API.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic