Hi,
I'm writing a bit of tooling so that my app defaults to bulk HQL deletes where possible. This is to squeeze a bit more performance out of my app. However this can potentially leave the data in the session stale because HQL deletes by-pass the session level cache. In the depths of the legacy code in which I am working, where deletes and inserts are common, NonUniqueObjectExceptions gets thrown all over the place.
I could evict the all instances of the entity class being deleted from the session level cache. This may cause problems the other way around because entities added to the session may be evicted before they have been flushed to the database.
What I would like to be able to do is evaluate whether a particular entity satisfies the HQL "where" clause in the delete statement. If it does, then I can evict it from the session level cache, knowing that it will have been deleted from the database by the bulk HQL delete.
I can't see any obvious methods to allow me do do this. I could crack open the HqlParser and do this myself but I suspect heading down this route will become a hefty coding task.
Thoughts?
|