简体   繁体   English

休眠会话无法在创建的下一个(新)会话中读取更新的数据

[英]hibernate session not reading updated data in next(new) session created

I am using Hibernate and spring in my web-app. 我在网络应用中使用Hibernate和spring。 On one forms submit i save some data in a table. 在一种形式上提交,我将一些数据保存在表格中。 the same controller that handles the submit redirects the page to another form. 处理提交的同一个控制器会将页面重定向到另一种形式。 ie to another form controller. 即到另一个表单控制器。 this form must use some data depending on the data submitted in last form before opening.i create a new hibernate session to fetch data. 此表单必须使用一些数据,具体取决于打开前最后提交的数据。我创建一个新的休眠会话以获取数据。

but for some reason it is not able to read updated data from the table( it reads old data). 但是由于某种原因,它不能从表中读取更新的数据(它读取旧数据)。 I have make sure to commit the transaction (It do save data i have checked in data base.) I also made sure to close session. 我确保提交事务(它确实保存了我已在数据库中检查的数据。)我还确保关闭会话。

I create a new session for each request and close this session, before moving back to view. 我为每个请求创建一个新会话,然后关闭该会话,然后再返回查看。

Why hibernate is not able to read new data? 为什么休眠无法读取新数据?

Initially i believed its cache problem but since second level cache is not applied and session is new in new form so first level cache is also not a problem. 最初我相信它的缓存问题,但是由于第二级缓存未应用并且会话以新形式出现,因此第一级缓存也不是问题。

what exactly is the problem is still a mystery but i got a work-around 问题到底是什么仍然是个谜,但我有一个解决方法

i added following property in my configuration with value 2 我在配置中添加了以下属性,值为2

"hibernate.connection.isolation" “休眠。连接。隔离”

It fixed my problem. 它解决了我的问题。 but More details about it is welcome as I am not clear what is this about. 但是欢迎提供更多详细信息,因为我不清楚这是什么意思。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM