我有两种方法来获取具有两个不同参数的实体。我还有一个保存方法,它使用这些参数之一。如何将实体从两个获取键下的缓存中删除?public User getByUsername(String username);
public User getByEmail(String email);
User save(User entity);
在上述情况下,调用getByEmail将返回过期日期。
我在我的大多数春季数据存储库上使用了spring @Cacheable注释。这包括findById(...)方法。org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
这是我的存储库但在我看来,这是一个糟糕的解决方案,因为我必须对代码段中使用的所有方法这样做,在这
我正在用EHCache测试Spring的@Cacheable特性,但是我找不到任何关于这是否适用于Spring的@Transactional注解的东西。我将@Cacheable和@CacheEvict放在DAO方法上,而@Transactional放在服务方法上。user.setFriendCount(--numFriends); // do some other stuff如何确保这不会在数据库事务完