views:

38

answers:

2

I have an application 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.

A: 

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.

Aaron Digulla
A: 

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.

Ustaman Sangat