Version info:
hibernate-annotations-3.4.0.GA.jar
hibernate-core-3.3.2.GA.jar
hibernate-entitymanager-3.4.0.GA.jar
I'm currently working on a interceptor for a more condensed form of logging than envers gives me(I need a single table to rebuild what happened more efficiently and send notifications to interested listeners in other apps). However, I'm running into some trouble with removals from collections. Previous state always has the same contents as current state(its the same collection object).
Is this intended? If so the only way I see around this is to always do shallow copies of collections and their contents and cache them in order to do the dirty checking myself? But since hibernate is clearly detecting this field as dirty(updates my association table just fine), I would have expected it to do something along those lines for me.
Here is my particular property mapping in case its related.
Code:
@ManyToMany(
cascade = { CascadeType.MERGE, CascadeType.PERSIST})
@JoinTable(
name="vehicle_association",
joinColumns={@JoinColumn(name="parent_id")},
inverseJoinColumns={@JoinColumn(name="vehicle_id")}
)
@Fetch(FetchMode.SUBSELECT)
private Set<Vehicle> vehicles=new HashSet<Vehicle>();
I've tried both ways of first merging a detached object, and just straight loading of the object via entityManager.find(..), followed by removal of vehicles from the set, just in case for some unknown reason previous state could not be determined using one method or the other.
Any info on whether or not this is working as designed or not would be helpful. Or if I can be pointed to a recipe for achieving what I want that would be great too.