-->
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.  [ 1 post ] 
Author Message
 Post subject: SecondLevelCacheStatistics and load cache values
PostPosted: Thu Dec 21, 2006 5:11 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Mapping documents:

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

    <class name="it.inform.ob.bean.Mercato" table="OBT_DIM_MERCATI" mutable="false">
       <meta attribute="class-description">Mercati</meta>
        <id name="codice" type="string" unsaved-value="null">
            <column name="cafmrc" sql-type="string" not-null="true" length="20"/>
            <generator class="assigned"/>
         </id>

        <property name="descrizione" type="string">
            <column name="dscmrc" length="100" sql-type="string" not-null="true"/>
        </property>
       
        <property name="livello" type="integer">
            <column name="codlivmrc" length="5" sql-type="integer" not-null="true"/>
        </property>

        <property name="flagneg" type="string">
            <column name="stsmrcneg" length="1" sql-type="string" not-null="true"/>
        </property>
       
        <property name="flagbudget" type="string">
            <column name="stsmrcbdg" length="1" sql-type="string" not-null="true"/>
        </property>
       
        <property name="codicelv6" type="string">
            <column name="cafmrclv6" length="20" sql-type="string" not-null="true"/>
        </property>

        <property name="desclv6" type="string">
            <column name="dscmrclv6" length="50" sql-type="string" not-null="true"/>
        </property>
       
        <property name="codicelv5" type="string">
            <column name="cafmrclv5" length="20" sql-type="string" not-null="true"/>
        </property>

        <property name="desclv5" type="string">
            <column name="dscmrclv5" length="50" sql-type="string" not-null="true"/>
        </property>

        <property name="codicelv4" type="string">
            <column name="cafmrclv4" length="20" sql-type="string" not-null="true"/>
        </property>

        <property name="desclv4" type="string">
            <column name="dscmrclv4" length="50" sql-type="string" not-null="true"/>
        </property>
       
        <property name="codicelv3" type="string">
            <column name="cafmrclv3" length="20" sql-type="string" not-null="true"/>
        </property>

        <property name="desclv3" type="string">
            <column name="dscmrclv3" length="50" sql-type="string" not-null="true"/>
        </property>
       
        <property name="codicelv2" type="string">
            <column name="cafmrclv2" length="20" sql-type="string" not-null="true"/>
        </property>

        <property name="desclv2" type="string">
            <column name="dscmrclv2" length="50" sql-type="string" not-null="true"/>
        </property>
       
        <property name="codicelv1" type="string">
            <column name="cafmrclv1" length="20" sql-type="string" not-null="true"/>
        </property>

        <property name="desclv1" type="string">
            <column name="dscmrclv1" length="50" sql-type="string" not-null="true"/>
        </property>

    </class>
     
</hibernate-mapping>



In hibernate.cfg.xml:

Code:
<class-cache class="it.inform.ob.bean.Mercato"                 usage="read-only"/>   



Code between sessionFactory.openSession() and session.close():

Code:
        Statistics stat = ((HibernateDAOServiceImpl)this.appContainer.getDaoService()).getSessionFactory().getStatistics();       
        if (stat.getSecondLevelCacheStatistics(classMapping.getEntityName()) != null){
            try{
                Map map = stat.getSecondLevelCacheStatistics(classMapping.getEntityName()).getEntries();
                map.size();
            }
            catch(CacheException ex){
                ex.printStackTrace();
            }



Name and version of the database you are using: Oracle 9.02




With this code i have not exception found, but i need to use statistics to load this type o POJO with out execute the query. I try to explain:

the table has more then 5000 records but only once a month they could change ..., so after the execute of the first time i would like to use SecondLevelCahce and load a List with all entries found in statistics

the problem is the methodo stat.getSecondLevelCacheStatistics("...").getEntries(); return a Map object with key value like the key of DTO and value like a map of all properties...
which is the best way to load a collection of all entries (statistics)?

Thanks

[/code]


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

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.