-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 14 posts ] 
Author Message
 Post subject: unable to insert/update BO when using second level caching.
PostPosted: Wed Aug 04, 2004 11:55 am 
Newbie

Joined: Fri Nov 28, 2003 10:38 am
Posts: 19
if hibernate.cache.use_query_cache=true
I get the below exception(The net.sf.hibernate.cache.UpdateTimestampsCache Cache is not alive) when i try to insert/update a BO.

if hibernate.cache.use_query_cache=false; i am able to update/insert BO.

Any help or advice appreciated.


Config
Code:
Hibernate 2.1.4
net.sf.ehcache.hibernate.Provider
Oracle 9x


Code
Code:
Session session = sf.openSession();
Connection c = session.connection();
Review r = new ReviewImpl("raj", 2, "sdf", true);
session.save(r);
session.flush();
session.close();


Mapping
Code:
<hibernate-mapping>
    <class name="uk.co.ReviewImpl" proxy="uk.co.idbs.product.Review" table="pd_reviews">
        <cache usage="read-write"/>
        <id name="id" column="id" type="string" unsaved-value="null">
            <generator class="uuid.hex"/>
        </id>
        <version name="auditVersion"/>

        <property name="reviewer" type="string"/>
        <property name="score" type="integer"/>
        <property name="comment" type="string" column="cment"/>
        <property name="buyAgain" type="yes_no"/>
    </class>
</hibernate-mapping>


Exception
Code:
Caused by: net.sf.hibernate.cache.CacheException: java.lang.IllegalStateException: The net.sf.hibernate.cache.UpdateTimestampsCache Cache is not alive.
   at net.sf.ehcache.hibernate.Plugin.put(Plugin.java:149)
   at net.sf.hibernate.cache.UpdateTimestampsCache.preinvalidate(UpdateTimestampsCache.java:42)
   at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2413)
   at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
   at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
   at idbs.impl.keystone.provider.hibernate.HibernateConnection.flush(HibernateConnection.java:459)
   ... 6 more
Caused by: java.lang.IllegalStateException: The net.sf.hibernate.cache.UpdateTimestampsCache Cache is not alive.
   at net.sf.ehcache.Cache.checkStatus(Cache.java:408)
   at net.sf.ehcache.Cache.put(Cache.java:201)
   at net.sf.ehcache.hibernate.Plugin.put(Plugin.java:145)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 11:57 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Debug log from Hibernate startup, please.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:06 pm 
Newbie

Joined: Fri Nov 28, 2003 10:38 am
Posts: 19
Code:
DEBUG: cache for: uk.co.idbs.product.impl.ReviewImpl usage strategy: read-write
INFO : starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
INFO : starting query cache at region: net.sf.hibernate.cache.QueryCache


and i get the exception


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:07 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Do you rebuild the SessionFactory in between?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:12 pm 
Newbie

Joined: Fri Nov 28, 2003 10:38 am
Posts: 19
yes. The main module loads all the BO in SessionFactory & the security pluggin builds a new SF to load all security objects. Is that a issue?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:13 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, do you call buildSessionFactory() twice in your application?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:14 pm 
Newbie

Joined: Fri Nov 28, 2003 10:38 am
Posts: 19
If i use net.sf.hibernate.cache.HashtableCacheProvider i do not get this problem, but the documentation reckons that HashtableCacheProvider is not intended for production use


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:15 pm 
Newbie

Joined: Fri Nov 28, 2003 10:38 am
Posts: 19
yes


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:16 pm 
Newbie

Joined: Fri Nov 28, 2003 10:38 am
Posts: 19
both main module and the plugin run in the same jvm


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:17 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This problem only appears with EHCache and more than one buildSessionFactory() call. Somehow EHCache gets stopped during rebuild. We'll have to look into this, please report it on JIRA.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 5:30 pm 
Regular
Regular

Joined: Thu Aug 28, 2003 6:30 am
Posts: 58
christian wrote:
This problem only appears with EHCache and more than one buildSessionFactory() call. Somehow EHCache gets stopped during rebuild. We'll have to look into this, please report it on JIRA.


Had this problem was solved already?
I have the same problem on Hibernate 3.0.3, ehcache 1.1, ibm jdk 1.3.1, oracle 9.0.1 and spring 1.2.
Now i get this problem in my unit tests.
Code:
00:18:25,912 DEBUG LeadHibernateHome:113 - Deleting a lead with id 95
00:18:27,184 ERROR AbstractFlushingEventListener:277 - Could not synchronize database state with session
org.hibernate.cache.CacheException: java.lang.IllegalStateException: The org.hibernate.cache.UpdateTimestampsCache Cache is not alive.
   at org.hibernate.cache.EhCache.put(EhCache.java:159)
   at org.hibernate.cache.UpdateTimestampsCache.preinvalidate(UpdateTimestampsCache.java:54)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:235)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:488)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 11:01 am 
Newbie

Joined: Fri Mar 26, 2004 1:01 pm
Posts: 12
It may be caused by Spring rebuilding the session factory if your Hibernate stuff is in an EJB. If an EJB instance is destroyed by the container (because of an unchecked exception, for example), Spring will re-initialize Hibernate completely by default. There's an FAQ for dealing with this, but I can't find it at the moment. The FAQ basically has some sample code to have Spring load the Hibernate configuration once, and then when another bean is instantiated to use the configuration that it loaded the first time.

If you find the snippet, could you please post a link?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 1:46 pm 
Regular
Regular

Joined: Thu Aug 28, 2003 6:30 am
Posts: 58
but if i need to re-initialize it, what should i do ?
koehn wrote:
It may be caused by Spring rebuilding the session factory if your Hibernate stuff is in an EJB. If an EJB instance is destroyed by the container (because of an unchecked exception, for example), Spring will re-initialize Hibernate completely by default. There's an FAQ for dealing with this, but I can't find it at the moment. The FAQ basically has some sample code to have Spring load the Hibernate configuration once, and then when another bean is instantiated to use the configuration that it loaded the first time.

If you find the snippet, could you please post a link?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 4:55 pm 
Newbie

Joined: Fri Mar 26, 2004 1:01 pm
Posts: 12
Quote:
but if i need to re-initialize it, what should i do ?

Either don't re-initialize it, use a different cache provider, file a JIRA on the issue, or fix the bug and submit a patch.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 14 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.