If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I believe that you can achieve what you're after with a combination of the [InvalidateCache(...)] attribute and using Spring Expression Language (SPeL) to leverage wildcards to define the keys to invalidate.

I had a brief look a that already, but I was not sure how to write that SPeL properly. I will look into that again and play with it. I'll let you know if I can find a solution.

But we actually ran into a massive problem in the meantime, which is currently stopping us from using spring AOP caching. And that makes me really sad, because it has a lot of potential regarding boosting our applications performance.

As you can see for cache key generation we use the nested Property "_messageTemplate.mandator.Id". Now our problem is, that we use a PersistenceLayer that supports lazy loading and therefore sometimes the Mandator property will be of type 'Mandator' sometimes 'MandatorGenerated'. Unfortunately spring caches the property infos of all nested properties, so if we first call the method with a MandatorGenerated and afterwards with a Mandator object, we will get the following exception:

The error message says, that MessageTemplate cannot be casted to MessageTemplateGenerated, but we debugged Spring and found out, that the actual error occurs in the nested property Mandator, which Spring tries to cast to MandatorGenerated.

Is there any solution to this issue? I think this could also happen with normal inherited types, not just with our persistence layer, but i'm not sure about that.