Reputation: 628
I have an owner (Category) and a customer (Forum) entities designed this way:
Category
...
@OneToMany( fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "category" )
@OrderBy( "position" )
private List<Forum> forums;
...
Forum
...
@ManyToOne
@JoinColumn( name = "category" )
private Category category;
private Integer position;
...
Somewhere in my webapp, I display the forums list, and I execute some business action on one of them, for example changing its position.
My issue is that the change is well persisted in the database, but is not reflected on the OneToMany mapped collection. Thus when I refresh the page that displays the list, it doesn't show the new position but the previous one.
The code I use to update an element's position is equivalent to a simple em.merge( forum )
. I read in many topics that I should "manually manage" the bidirectionnal relationship, otherwise I would face this kind of issues. Here are my two questions :
[EDIT] I read this topic and I feel my issue is related to my forum being updated by a different session from the one being used to fetch the list. Am I understanding it right? If yes, how to correctly manage that case?
Upvotes: 2
Views: 1118
Reputation: 86845
Assuming you set both sides of the objects (you have to!), try disabling the eclipselink cache:
<property name="eclipselink.cache.shared.default" value="false"/>
@source http://wiki.eclipse.org/EclipseLink/FAQ/How_to_disable_the_shared_cache%3F
Upvotes: 1