Hibernate Bi-Directional ManyToMany Updates with Second Level cache

Posted by DD on Stack Overflow See other posts from Stack Overflow or by DD
Published on 2010-06-01T16:05:03Z Indexed on 2010/06/01 21:53 UTC
Read the original article Hit count: 239

Filed under:

I have a bidirectional many-to-many class:

public class A{
 @ManyToMany(mappedBy="listA")
 private List<B> listB;
}
public class B{
 @ManyToMany
 private List<A> listA;
}

Now I save a listA into B:

b.setListA(listA);

This all works fine until I turn on second-level caching on the collection a.ListB. Now, when I update the list in B, a.listB does not get updated and remains stale.

How do you get around this?

Thanks, Dwayne

© Stack Overflow or respective owner

Related posts about hibernate