Hi all,
I have a second level cache which I am using with my hibernate sessions. I am getting my session factory from JNDI and creating a session each request as described in "Hibernate In Action".
I am having a problem though after I delete or update an object. The changes can be immediately seen in the database. But, the references to the objects in the cache are either not removed or not updated. If I then wait about 30 seconds and try again everything is updated.
What do I need to set or change so that changes are automatically reflected in the cache as well as the database?
Cheers
Tom
Hibernate version: JBoss 4.0.2 (I think its 2.1.7)
Config documents:
<server>
<mbean code="org.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,
name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<!-- Make it deploy ONLY after DataSource had been started -->
<!-- <depends>jboss.jca:name=LocalTxCM,name=PostgresDS</depends> -->
<attribute name="MapResources">
com/camp/common/accounting/ApplicationAccounting.hbm.xml,
com/camp/common/action/Action.hbm.xml,
...</attribute>
<attribute name="JndiName">java:/CAMP/HibernateFactory</attribute>
<attribute name="Datasource">java:/PostgresDS</attribute>
<attribute name="Dialect">org.hibernate.dialect.PostgreSQLDialect</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
<attribute name="SecondLevelCacheEnabled">true</attribute>
<attribute name="CacheProviderClass">org.hibernate.cache.EhCacheProvider</attribute>
<attribute name="QueryCacheEnabled">true</attribute>
</mbean>
</server>
Full stack trace of any exception that occurs:
This stack trace happens after I delete an object and then try to list a set of objects which used to include the deleted object. (If that makes any sense)
00:21:43,337 INFO [STDOUT] Hibernate: select menuitem0_.id_menu_item as id1_0_, menuitem0_.name as name65_0_, menuitem0
_.next_menu as next3_65_0_, menuitem0_.fk_id_menu as fk4_65_0_, menuitem0_.fk_id_role as fk5_65_0_ from tblMenuItem menu
item0_ where menuitem0_.id_menu_item=?
00:21:43,347 INFO [DefaultLoadEventListener] Error performing load command
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.camp.common.menu.MenuItem#1608]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at
Name and version of the database you are using:
Postgres 8.0
|