steve wrote:
Interceptor.findDirty()
Or is it more that you want to track which are dirty yourself somehow and avoid the looping here during flush?
That's exactly what we were thinking, we admittedly are using Hibernate in a slightly different manner to most of the web-apps and app server based implementations I've seen mentioned here. We've a swing fat client for complex network design and provisioning, our domain model is huge... Hibernate actually replaced a bespoke persistence mechanism reasonable painlessly as we had a wrapper layer that sits around the persistent object (now a hibernate pojo) and holds the business logic, this layer also manages the referential integrity of the model changes and has been modified to record which entities and accessors have been modified. This modified cache is currently tied to have a lifespan controlled by the Interceptor's postFlush() method. We have implemented the findDirty() method to use this information but it was far less of a performance improvement than removing the loop over the entire session cache.
Having profiled our app we were surprised to see that 90% if the processing was being taken up iterating in the flush mechanism. We figured that if there was some way to pass you the information on what actually has changed since the last flush that would massively improve performance (and it did with our hack which no longer works in 3.0.2).
steve wrote:
Really I'd think that applying better control over the amount of entities in your session cache would be the correct solution.
Unfortunately we've gone as far as we can with minimising the number of objects in the cache, we've implemented a better session management system to restrict the number of extra objects in the cache and that helped (session per transaction) and this particular performance area can't be broken down any more, it is particularly complex.