开发者

Database changes done by one instance of an application is not being picked up another instance using Hibernate

I have an a开发者_StackOverflow社区pplication which can read/write changes to a database table. Another instance of the same application should be able to see the updated values in the database. i am using hibernate for this purpose. If I have 2 instances of the application running, and if i make changes to the db from one instance for the first time, the updated values can be seen from the second. But any further changes from the first instance is not reflected in the second. Please throw some light.


This seems to be a bug in your cache settings. By default, Hibernate assumes that it's the only one changing the database. This allows it to efficiently cache objects. If several parties can change tables in the DB, then you must switch off caching for those tables/instances.


You can use hibernate.connection.autocommit=true

This will make hibernate commit each SQL update to the database immediately and u should be able to see the changes from the other application.

HOWEVER, I would strongly discourage you from doing so. Like Aaron pointed out, you should only use one Hibernate SessionFactory with a database.

If you do need multiple applications to be in sync, think about using a shared cache,e.g. Gemstone.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜