Quantcast

How to enforce springcache to execute before transaction manager?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

How to enforce springcache to execute before transaction manager?

dmurat
This post has NOT been accepted by the mailing list yet.
Hi,

I'm trying to figure out how to force springcache aspects on service methods to execute before GrailsHibernateTransactionManager.
Is this possible to do it declaratively, or somehow through configuration?
Tnx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to enforce springcache to execute before transaction manager?

dmurat
This post has NOT been accepted by the mailing list yet.
Didn't found declarative way, but here is a workaround:

In your services
  - transactional = false
  - use @Transactional and @Cahcable as needed
 
In springcache plugin
  - in grails.plugin.springcache.aop.CachingAspect add something like this
 
    ...
    import org.springframework.core.annotation.Order
   
    @Aspect
    @Order(value=100000)  // This line is added. value can be any integer smaller then Ordered.LOWEST_PRECEDENCE
    class CachingAspect implements ApplicationContextAware {
    ...
   
With all this in place, caching aspect is executed before transaction aspect.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to enforce springcache to execute before transaction manager?

dmurat
This post has NOT been accepted by the mailing list yet.
It seems that declarative way is possible after all, but it is a bit more involved.

More details, with an included patch for springcache plugin, can be found here:
http://jira.codehaus.org/browse/GRAILSPLUGINS-2803
Loading...