-->
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: Returning null values from Query cache (Bug?)
PostPosted: Thu Aug 16, 2007 4:48 am 
Newbie

Joined: Thu Aug 16, 2007 3:36 am
Posts: 2
Hibernate version: 3.2.4

Hi,

I'm using the query cache with Ehcache and the JPA implementation.

My request returns 3 elements from the database. Everything is fine.
But when Hibernate tries to retrieve the objects from the query cache the list is composed of null objects,

Here is the logs:

DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC Connection to [jdbc:oracle:thin:@psdev01:1522:IDTV3DU2]
DEBUG org.hibernate.SQL - select * from ( select episodes1_.XID as XID0_, episodes1_.COMMENTS as COMMENTS0_, episodes1_.MAIN_CONTENT_ID as MAIN13_0_, episodes1_.PUBLIC_ID as PUBLIC4_0_, episodes1_.TITLE as TITLE0_, episodes1_.TYPE_SUBTYPE_LIST as TYPE6_0_, episodes1_.VERSION as VERSION0_, episodes1_.APPROX_DURATION as APPROX8_0_, episodes1_.SEASON_ID as SEASON11_0_, episodes1_.SEQ_NUMBER as SEQ9_0_, episodes1_.SEQ_NUMBER_DISPLAY as SEQ10_0_, episodes1_.CLASS as CLASS0_ from DT3_CON_CONTENT season0_ inner join DT3_CON_CONTENT episodes1_ on season0_.XID=episodes1_.SEASON_ID where season0_.CLASS='com.lysis.idtv3.content.adaptors.PSeason' and season0_.XID=? ) where rownum <= ?
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.lysis.idtv.model.VideoContent#38856]
DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.lysis.idtv.model.VideoContent#165666]
DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.lysis.idtv.model.VideoContent#165665]
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [com.lysis.idtv.model.Production#38856]
DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [com.lysis.idtv.model.Production#38856]
DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [com.lysis.idtv.model.Production#165666]
DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [com.lysis.idtv.model.Production#165666]
DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [com.lysis.idtv.model.Production#165665]
DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [com.lysis.idtv.model.Production#165665]
DEBUG org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy collections
DEBUG org.hibernate.cache.StandardQueryCache - caching query results in region: org.hibernate.cache.StandardQueryCache; timestamp=4862990954733569
DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection

....

Great, I have my 3 objects:
INFO com.XXX.service.impl.SeriesServiceImpl - results = [com.lysis.idtv.model.Production@1563e06, com.lysis.idtv.model.Production@10204ce, com.lysis.idtv.model.Production@1898b92]

....

And then for the next calls:

...

DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 4862990955245572
DEBUG org.hibernate.cache.StandardQueryCache - checking cached query results in region: org.hibernate.cache.StandardQueryCache
DEBUG net.sf.ehcache.hibernate.EhCache - key: sql: select episodes1_.XID as XID0_, episodes1_.COMMENTS as COMMENTS0_, episodes1_.MAIN_CONTENT_ID as MAIN13_0_, episodes1_.PUBLIC_ID as PUBLIC4_0_, episodes1_.TITLE as TITLE0_, episodes1_.TYPE_SUBTYPE_LIST as TYPE6_0_, episodes1_.VERSION as VERSION0_, episodes1_.APPROX_DURATION as APPROX8_0_, episodes1_.SEASON_ID as SEASON11_0_, episodes1_.SEQ_NUMBER as SEQ9_0_, episodes1_.SEQ_NUMBER_DISPLAY as SEQ10_0_, episodes1_.CLASS as CLASS0_ from DT3_CON_CONTENT season0_ inner join DT3_CON_CONTENT episodes1_ on season0_.XID=episodes1_.SEASON_ID where season0_.CLASS='com.lysis.idtv3.content.adaptors.PSeason' and season0_.XID=?; parameters: ; named parameters: {season=39092}; first row: 0; max rows: 3
DEBUG org.hibernate.cache.StandardQueryCache - Checking query spaces for up-to-dateness: [DT3_CON_CONTENT]
DEBUG net.sf.ehcache.hibernate.EhCache - key: DT3_CON_CONTENT
DEBUG net.sf.ehcache.hibernate.EhCache - Element for DT3_CON_CONTENT is null
DEBUG org.hibernate.cache.StandardQueryCache - returning cached query results
DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
...

An now the values are null:
INFO com.XXX.service.impl.SeriesServiceImpl - results = [null, null, null]



Any ideas?
Thanks in advance.
J.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 8:07 am 
Newbie

Joined: Thu Aug 16, 2007 3:36 am
Posts: 2
Does someone use query cache (Ehcache) and Jpa?

Just to know if I did something wrong.

Thanks.
J.


Top
 Profile  
 
 Post subject: wrong configuration of EhCache
PostPosted: Thu Aug 16, 2007 11:24 am 
Newbie

Joined: Wed Aug 15, 2007 3:50 pm
Posts: 6
Location: Philadelphia
Do you have your ehcache.xml file properly configured?

My cached queries were not retrieving the objects properly until I set up the objects *themselves* in ehcache.xml. Until that happened, it was noticing that the query had been executed before, but it was failing to find the objects of the result-set.

Here's an example of declaring the objects themselves in the ehcache.xml:


Code:
<ehcache>
  <cache
        name="com.carescience.soc.beans.SocCodeDefinition"
        maxElementsInMemory="100"
        eternal="true"
        overflowToDisk="false"
    />
   ......
   ......
   <cache
       name="net.sf.hibernate.cache.StandardQueryCache"
       maxElementsInMemory="50"
       eternal="false"
       timeToIdleSeconds="500"
       timeToLiveSeconds="0"
       overflowToDisk="false"
   />

</ehcache>

_________________
Melina Schweizer


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.