禁用EclipseLink缓存 [英] Disabling EclipseLink cache

查看:69
本文介绍了禁用EclipseLink缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,当用户登录系统时,系统会从数据库中读取某些设置并将其存储在用户会话中。系统正在通过使用EclipseLink(JPA 2.0)的JPA查询执行此操作。

In my application, when user logs in to the system the system reads some setting from DB and stores them on user's session. The system is performing this action by a JPA query using EclipseLink (JPA 2.0).

当我更改数据库中的某些设置并再次登录时,查询将返回以前的结果。似乎EclipseLink正在缓存结果。

When I change some settings in DB, and sign in again, the query returns the previous results. It seems that EclipseLink is caching the results.

我已使用它来纠正此行为,但它不起作用

I have used this to correct this behavior but it does not work:

query.setHint(QueryHints.cache_usage,cacheUsage.no_cache);


推荐答案

如果要设置查询提示,则文档建议这样做:

If you want to set query hints, the docs recommend doing:

query.setHint("javax.persistence.cache.storeMode", "REFRESH");

您可以交替设置受影响实体的 @Cacheable 注解

You can alternately set the affected entity's @Cacheable annotation

@Cacheable(false)
public class EntityThatMustNotBeCached {
...
}

这篇关于禁用EclipseLink缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆