Hi, I have discovered that adding the where attribute in the mapping file of a class "disable" the second level cache lookup for that entities (with EhCache).
So I'm trying to do the same filtering (logical delete) in memory after all the data has been loaded from db, both for lookup and queries. Deleted lines are really few so this will not be a performance problem.
In practice I'd like to be able to intercept each record loaded and choose to discard some. I looked atInterceptors but I think this can not be used to do this. I checked both onLoad(), instantiate() and getEntity() but none can return anything to signal to completely discard the record. Filters do the filtering on the database side so are not useful here.
I'm considering to subclass DefaultLoadEventListener and "decorate" the doLoad method with this filtering. Is this a good idea? Is there any better way to do this?
Thanks, bye
Lorenzo
|