dimanche 12 avril 2015

About Spring cache annotation and Mybatis, can I place the @Cacheable/CacheEvict on a method on an mapper interface?

I place the @Cacheable/CacheEvict on a method on an mapper interface, then the SpEL could not get the parameters.



public interface UserMapper {
@CacheEvict(value="user",key="(#user.id)")
public int updateUser(User user);
}


The above code, I got error:



EL1007E:(pos 18): Property or field 'id' cannot be found on null


Everything is ok like this:



public class UserService {

@CacheEvict(value="user",key="(#user.id)")
public int updateUser(User user){
return userMapper.updateUser(user);
}
}


Question: Can I place the @Cacheable/CacheEvict on a method on an interface ?


Thanks!!


Aucun commentaire:

Enregistrer un commentaire