Essentially my situation is thus.
I have an object Foo with two OneToMany relationships, a list of other Foos (children) and a list of Bars, both these relationships are managed on the ManyToOne side and the OneToMany uses a mappedBy.
At some point I need to take an action depending on whether any Bar contained in a Foo has a property moo set, ie if foo.getFoos().get(0).getFoos().get(1).getBars().get(0).isMoo() == true then the action is taken.
For performances sake I cache this result in a transient property, and when Bar.setMoo() is called it tells the chain of Foos containing it that the cached result needs to be recalculated.
Essentially my problem is that when a Bar is updated using another session how can I detect the update?
CascadeType.REFRESH isn't an option, even if the mappedBy didn't forgo this possibility it simply takes too long to run the N selects.
Now the Bar objects are updated infrequently, this what I want to do is (cheaply) query for a list of Bar objects who have had their version property changed since they were last loaded/refresh so I can refresh them. Is such a query possible? My hunch says no but I thought it was worth asking.
I suppose it's possible to accomplish this with @timestamp though we're already using @version and I don't want to have to worry about issues with unsynchronized clocks on different machines.
thanks,
Aaron
|