Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.1ga
(NOTE: I don't believe this is a bug or performance problem in Hibernate. Most likely, it's my usage of it).
I'm noticing that Session.flush() takes progressively longer as I add entities to Hibernate's session cache.
What's especially odd is that the most expensive operations are not the ones that cause hits to the database for queries, inserts, or updates. JProfiler shows that most of the time is spent in one method, AbstractFlushingEventListener.flushEverythingToExecutions(). As far as I can tell, this method doesn't cause many trips to the database, and where it does (to get the next sequence number for a surrogate key), the underlying SQL call isn't expensive or frequent.
Are there any ways to cut down the cost of this method?
BTW, I've tried making some of our mapped classes immutable, which makes a small difference in the number of dirty checks, but not a really large difference.