gavin wrote:
Talk about doing things the hard way.
implement Interceptor.findDirty()
Or just call flush() manually when you know you need to.
I quite agree, it was the hard way - that flushing code is rather complex! :) Okay, we already have implemented the findDirty() interceptor although the profiling that we did indicated that this wasn't the hotspot (although it did make a small difference).
That findDirty however only returns the attributes on the pojo specified as a parameter that are dirty, what we really wanted was a findDirty that we could implement that would provide Hibernate with ALL the pojos / parameters that were dirty in one hit. That would remove all of the loops in the Hibernate flush code that have to hit hit every single pojo and collection. It was in this general processing that the time was taken, presumably as we have a very large & highly connected session cache at this point.
Mind you, I am assuming that its not as simple as I put it above,
a) because no such API exists in Hibernate, and if it was that straight-forward I would imagine it would be there.
&
b) because something else is happening in this flush code as when I stopped Hibernate iterating over all pojos/collections things started started to misbehave.
As for manually calling flush()... due to the nature of the calculations, stale data and the finders we wish to use, we need to flush... We want these flushes to happen its just that they take too long.