-->
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.  [ 2 posts ] 
Author Message
 Post subject: Object not found in cache even when L2 is enabled
PostPosted: Thu Apr 27, 2006 3:19 pm 
Regular
Regular

Joined: Wed Jul 27, 2005 2:33 am
Posts: 118
Hi,
We are using Hibernate-3.1.2. Most of our hibernate objects are second-level cache enabled. Every object is working fine, except for, one specific object 'AppDomain'.
We have enabled second level cache even for this object also. But, everytime we try to get this object, it runs a query against the database. Here's the mapping file:


Code:
<hibernate-mapping default-lazy="false">

<class
    name="com.dbdata.metadata.hibernateobject.AppDomain"
    table="CR_DOMAIN"
        lazy="false"
>
    <cache usage="transactional"/>
    <composite-id name="id" class="com.dbdata.metadata.hibernateobject.AppDomainId">
        <key-property
            name="domainName"
            column="DOMAIN_NAME"
            type="java.lang.String"
            length="40"
        >
        </key-property>
       
        <key-property
            name="domainCd"
            column="DOMAIN_CD"
            type="short"
            length="22"
        >
        </key-property>
    </composite-id>   
   
    <property
            name="domainValueName"
            type="java.lang.String"
            column="DOMAIN_VALUE_NAME"
            length="40"
        >
        </property>
       
        <property
            name="domainValueDescription"
            type="java.lang.String"
            column="DOMAIN_VALUE_DESCRIPTION"
            length="1000"
        >
    </property>
   
    </class>
    </hibernate-mapping>


Here's the hibernate logs:



Quote:
2006-04-28 00:42:47,203 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: -9223372036854775808
2006-04-28 00:42:47,203 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
2006-04-28 00:42:47,203 DEBUG [com.dbdata.system.persistence.SessionHandler] SessionHandler.getHibernateSession returning session:SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
2006-04-28 00:42:47,203 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] loading entity: [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,203 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] attempting to resolve: [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,203 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] object not resolved in any cache: [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,203 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Fetching entity: [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,203 DEBUG [org.hibernate.loader.Loader] loading entity: [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,203 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-04-28 00:42:47,203 DEBUG [org.hibernate.SQL] select AppDomain0_.DOMAIN_NAME as DOMAIN1_130_0_, AppDomain0_.DOMAIN_CD as DOMAIN2_130_0_, AppDomain0_.UPDATE_DTTM as UPDATE3_130_0_, AppDomain0_.DOMAIN_VALUE_NAME as DOMAIN4_130_0_, AppDomain0_.DOMAIN_VALUE_DESCRIPTION as DOMAIN5_130_0_, AppDomain0_.TRANSLATE_IND as TRANSLATE6_130_0_, AppDomain0_.DISPLAY_ORD as DISPLAY7_130_0_, AppDomain0_.UPDATE_USER as UPDATE8_130_0_ from CR_DOMAIN AppDomain0_ where AppDomain0_.DOMAIN_NAME=? and AppDomain0_.DOMAIN_CD=?2006-04-28 00:42:47,203 INFO [STDOUT] Hibernate: select AppDomain0_.DOMAIN_NAME as DOMAIN1_130_0_, AppDomain0_.DOMAIN_CD as DOMAIN2_130_0_, AppDomain0_.UPDATE_DTTM as UPDATE3_130_0_, AppDomain0_.DOMAIN_VALUE_NAME as DOMAIN4_130_0_, AppDomain0_.DOMAIN_VALUE_DESCRIPTION as DOMAIN5_130_0_, AppDomain0_.TRANSLATE_IND as TRANSLATE6_130_0_, AppDomain0_.DISPLAY_ORD as DISPLAY7_130_0_, AppDomain0_.UPDATE_USER as UPDATE8_130_0_ from CR_DOMAIN AppDomain0_ where AppDomain0_.DOMAIN_NAME=? and AppDomain0_.DOMAIN_CD=?
2006-04-28 00:42:47,203 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-04-28 00:42:47,203 DEBUG [org.hibernate.type.StringType] binding 'STATUS_CD' to parameter: 1
2006-04-28 00:42:47,203 DEBUG [org.hibernate.type.ShortType] binding '1' to parameter: 2
2006-04-28 00:42:47,218 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2006-04-28 00:42:47,218 DEBUG [org.hibernate.loader.Loader] processing result set
2006-04-28 00:42:47,218 DEBUG [org.hibernate.loader.Loader] result set row: 0
2006-04-28 00:42:47,218 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,218 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,218 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Hydrating entity: [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,218 DEBUG [org.hibernate.type.TimestampType] returning '2006-03-16 11:29:03' as column: UPDATE3_130_0_
2006-04-28 00:42:47,218 DEBUG [org.hibernate.type.StringType] returning 'Draft' as column: DOMAIN4_130_0_
2006-04-28 00:42:47,218 DEBUG [org.hibernate.type.StringType] returning null as column: DOMAIN5_130_0_
2006-04-28 00:42:47,218 DEBUG [org.hibernate.type.BooleanType] returning 'true' as column: TRANSLATE6_130_0_
2006-04-28 00:42:47,218 DEBUG [org.hibernate.type.IntegerType] returning '1' as column: DISPLAY7_130_0_
2006-04-28 00:42:47,218 DEBUG [org.hibernate.type.StringType] returning 'mstrm600bu' as column: UPDATE8_130_0_
2006-04-28 00:42:47,218 DEBUG [org.hibernate.engine.TwoPhaseLoad] Version: 2006-03-16 11:29:03.39
2006-04-28 00:42:47,218 DEBUG [org.hibernate.loader.Loader] done processing result set (1 rows)
2006-04-28 00:42:47,218 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2006-04-28 00:42:47,218 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-04-28 00:42:47,218 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-04-28 00:42:47,218 DEBUG [org.hibernate.loader.Loader] total objects hydrated: 1
2006-04-28 00:42:47,218 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,218 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.dbdata.metadata.hibernateobject.AppDomain#component[domainName,domainCd]{domainName=STATUS_CD, domainCd=1}]
2006-04-28 00:42:47,218 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
2006-04-28 00:42:47,218 DEBUG [org.hibernate.loader.Loader] done entity load


Hibernate is issuing the query every time we try to get this object. To make sure that the eviction policy had nothing to do with this, we invoked the get within a single method one after another. Even then it issued the database query.
Is there something wrong with the ids that we are using for this object?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 4:01 pm 
Regular
Regular

Joined: Wed Jul 27, 2005 2:33 am
Posts: 118
Please ignore the post, it was a bug in our code


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