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.02With 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]