bsed / ehcache-spring-annotations

Automatically exported from code.google.com/p/ehcache-spring-annotations
0 stars 0 forks source link

Facing issue while using with @Transactional #88

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I am currently facing issue while using ehcache along with transaction 
The settings of my application as goes below:

The main method Which I am making as transactional:
@Transactional(isolation=Isolation.REPEATABLE_READ,readOnly=true)
    public ItemInquiryResponse inquireItem(ItemInquiryRequest request) {
//Some codes goes here to call n number of services
like 
Unit unit = unitMapper.getUnit(Unit);
}

Here unitMapper, is a mapper class for Mybatis which is a interface and 
initialized from the spring Context.

and in the getUnit() I did like this:

@Transactional(isolation=Isolation.READ_UNCOMMITTED, readOnly=true)
public interface UnitMapper {
    @Cacheable(cacheName="com.sears.dos.ordermgmt.UNIT_CACHE", 
            keyGenerator = @KeyGenerator (name = "StringCacheKeyGenerator",
            properties = {
            @Property( name="useReflection", value="false" ),           @Property( name="checkforCycles", value="false" ),
            @Property( name="includeMethod", value="false" )
                        }
            )
        ) 

        public Unit getUnit(Unit unit);
}

Initially, I was facing issue like, on the first call of 

Unit unit = mapper.getUnit()
then I am trying to play with this unit object, It was getting corrupted in 
ehcache , So from the code level I am taking care of that, not to touch the 
persisted object.

When I am removing @Tranaction from the main method, the EhCache is working 
fine, While I including it seems to be not picking anything from cache.

My basic key understanding is, every method after execution should get cached 
regardless of transaction, when second time with same parameter I am trying to 
make call it should return me from the cache.

While this is not happening in my case.

I tried to look into logs of ehcache, but that didn't help me much.

Please do note all my objects are singeltone and all mapperinterfaces objects 
are instance variable and geting set by Spring IOC of setter injection, 

Please assist me on this ASAP.

your help is appreciated.

Thanks,
Jayaram. 

Original issue reported on code.google.com by jayarami...@gmail.com on 28 Oct 2011 at 6:55

GoogleCodeExporter commented 9 years ago
Hello,

I think this is an issue with key generator of type 

while we are passing property of 'checkforCycles' its not able to pass it to 
any any method parameters , as a result its failing to cache my method

I went through the java files and found like inside 
AbstractDeepCacheKeyGenerator we are manupilating with property useReflection 
and all apart from checkforCycles, 
code snippet as below:

 public AbstractDeepCacheKeyGenerator(boolean includeMethod, boolean includeParameterTypes) {
        super(includeMethod, includeParameterTypes);
    }

finally I removed that unused property and its work fine now.

So if u can suggest its the right one step or not, it will be great.

also please let me know for the property checkforCycles why its failing?

Thanks,
Jayaram

Original comment by jayarami...@gmail.com on 30 Oct 2011 at 9:59