-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Query cache error
PostPosted: Tue Jun 24, 2008 5:58 am 
Newbie

Joined: Wed Apr 23, 2008 10:51 am
Posts: 4
Location: Lebanon
Please if someone could help with this error.

We have a hibernate 3.2 java application integrated with oracle apps. we are using hibernate caching ehcache. an error occured while caching certain objects. error conditions:

1- Still in the same hibernate session.
2- one object deleted in the database but still in the cache.
2- open the lookup before timeToLiveSeconds expires (no error)
3- timeToLiveSeconds expired.
4- open the lookup another time (error)

FYI:When re logging into the application everything runs smoothly.

Hibernate version:3.2

Mapping documents:
ehcache.xml

<cache name="com.fp.deals.model.bo.lookups.Rights"
maxElementsInMemory="5000"
eternal="false"
timeToLiveSeconds="60"
overflowToDisk="true" />

hbm.xml

<class name="Rights" table="Rights_V">
<cache usage="read-only" />
<id name="id" column="RIGHT_RELATIONSHIP_ID"><generator class="native"/></id>
<property name="descr" column="description" type="java.lang.String" insert="false" update="false"/>
<property name="parentId" column="parent_id" type="java.lang.String" insert="false" update="false"/>
<property name="type" column="type_code" type="java.lang.String" insert="false" update="false"/>
<property name="rightId" column="right_id" type="java.lang.Long" insert="false" update="false"/>
</class>



getHibernateTemplate().setCacheQueries(true);
ArrayList<BaseLookup> list = (ArrayList<BaseLookup>) getHibernateTemplate().find("from " + className + " t " + whereSQL + orderBy);



Caused by: org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [com.fp.deals.model.bo.lookups.Rights#199]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.fp.deals.model.bo.lookups.Rights#199]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:642)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:832)
at com.fp.common.model.dao.hibernate.CommonLookupDaoHibernate.getList(CommonLookupDaoHibernate.java:197)
at com.fp.common.model.dao.hibernate.CommonLookupDaoHibernate.getLookUpList(CommonLookupDaoHibernate.java:228)
at com.fp.common.model.service.impl.CommonLookupServiceImpl.getLookUpList(CommonLookupServiceImpl.java:107)
at com.fp.common.model.service.impl.CommonLookupServiceImpl.getTreeRoot(CommonLookupServiceImpl.java:187)
at com.fp.common.view.backing.CommonLookupBB.getRoot(CommonLookupBB.java:220)
at com.fp.common.view.backing.CommonLookupBB.createTreeHTML(CommonLookupBB.java:358)
at com.fp.common.view.backing.CommonLookupBB.prepareInfo(CommonLookupBB.java:209)
at com.fp.common.view.backing.CommonLookupBB.init(CommonLookupBB.java:184)
at com.fp.common.view.bean.BaseBean.setServiceLocator(BaseBean.java:63)
... 60 more
Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.fp.deals.model.bo.lookups.Rights#199]
at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:145)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
at org.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:196)
at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:130)
at org.hibernate.loader.Loader.getResultFromQueryCache(Loader.java:2163)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2126)
at org.hibernate.loader.Loader.list(Loader.java:2096)
at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:912)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:849)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
... 71 more




Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 24, 2008 10:04 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
If you reversed the use of get with the use of load, you'd get a null object when you tried to access the object, rather than an ObjectNotFoundException when you try to access the data. You could handle the null object instead of trying to catch this exception.

Here's a little tutorial on the differences between using Hibernate load and Hibernate get methods.

http://jpa.ezhibernate.com/Javacode/lea ... bernateget

Just an idea.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Hibernate Query cache error
PostPosted: Wed Sep 01, 2010 12:31 pm 
Newbie

Joined: Thu Aug 12, 2010 12:56 pm
Posts: 1
Visit HibernateTemplate caching Using Jboss Tree cache
http://opensourceframework.blogspot.com/2010/08/caching-queries-with-hibernatetemplate.html
ANish


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.