开发者

how to force hibernate to load data from database?

开发者 https://www.devze.com 2023-03-26 19:17 出处:网络
Problem with hibernate: I update a column开发者_JS百科 \"count\" in a table \"data\" with a native query in my source code. Later I want to load all rows from table \"data\" but the value of column \

Problem with hibernate:

I update a column开发者_JS百科 "count" in a table "data" with a native query in my source code. Later I want to load all rows from table "data" but the value of column "count" has not changed.

Rows from table "data" are loaded with:

... .createQuery("from data") .setCacheable(false)

.list();

Any idea what's wrong ?


setCacheable(false) isn't useful (it's the default). The cache it refers to is the second-level cache. You probably have loaded some entities in the session (i.e. the first-level cache) before executing your update query. In this case, the select query will perform against the database, but will return the already-loaded entities from the session. You thus need to evict these entities from the session before executing the select query, or to completely clear the session.

If the entities are cached in the second-level cache, then you also have to evict them from the second-level cache. See getCache.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号