I have a database that is being acted on by several "agents". The user interface is a fairly simple web application. My problem is that changes made by other processes are not reflected in the web application.
That is to say, any changes made to the database after the webapp is initialized fail to appear on it.
Initially I thought it might be the first level cache. That the sessions were being reused. However I quickly ruled that out as each request ended with the hibernate session being properly closed and a new one being created for subsequent requests.
That led me to the second level cache which (as I understand) should be disabled by default. To further guard against this I added the following to my hibernate.cfg.xml:
<property name="cache.use_second_level_cache">false</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
just to make it absolutely clear. No change.
I then turned my attention to Tomcat. Figuring this might be some weirdness to do with it I created a very simple Test program
Code:
PublicationDAO pDAO = new PublicationDAO();
List<Publication> list = (List<Publication>)pDAO.findAll();
for(Publication p : list){
System.out.println(p.getName());
}
HibernateSessionFactory.closeSession();
Thread.sleep(5000);
Needless to say, the problem persisted. Turning on show_sql caused an SQL statement to be printed out for each iteration but any changes I made to the database failed to show up.
The HibernateSessionFactory is a (mostly) auto generated object (by MyEclipse) that follows the Thread Local Session pattern.
It was only when I added code to rebuild the SessionFactory it used (kept as a static variable) before getting a new session that the Test program started to reflect changes in the database as they occurred. However, repeatedly rebuilding the SessionFactory seems a sub-optimal solution (to say the least).
Unfortunately I'm now entirely out of ideas as to what may be causing this and would greatly appreciate any help and thoughts you may have.
Hibernate version: 3.1.3
Name and version of the database you are using: MySQL 5