按需清空 Hibernate 缓存

发布于 2024-09-07 15:04:51 字数 238 浏览 1 评论 0原文

我正在编写一个肥皂网络服务:Jboss + Hibernate + Java。 PostrgreSQL 上的数据库。发布webservice后,完美运行。

出于测试目的,我通过打开 pgAdmin 更改数据库上的数据,并手动更改行上的值。现在的问题是,Hibernate 不知道这些变化。直到我重新发布网络服务。

有没有办法告诉 Hibernate 清空缓存或从数据库重新加载数据,以便它采用最后可用的值?

谢谢!

I'm writing a soap web service: Jboss + Hibernate + Java. Database on PostrgreSQL. After publishing the webservice, it runs perfectly.

For testing purposes I change data on the database by opening pgAdmin, and changing the values on the rows by hand. Now, the problem is, Hibernate is not aware of those changes. Not until I re-publish the web service.

Is there any way to tell Hibernate to empty the cache or reload the data from the database so it will take the last values available?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不弃不离 2024-09-14 15:04:51

我假设您正在谈论二级缓存...

Cache API 公开了多种允许逐出各个区域的方法。检查所有 evictXxx() 方法。使用 SessionFactory#getCache( ) 获取缓存

I'm assuming you're talking about the second level cache...

The Cache API exposes several methods allowing to evict various regions. Check all the evictXxx() methods. Use SessionFactory#getCache() to obtain the Cache.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文