-->
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: Cache never expires
PostPosted: Fri Dec 10, 2010 3:13 pm 
Newbie

Joined: Mon Aug 09, 2004 2:50 pm
Posts: 10
Location: Sao Paulo , SP, Brazil
Hi all,

I have set a tipical Hibernate config, using this configurations:

AnnotationConfiguration configuration...
configuration.setProperty(Environment.DIALECT, Oracle10gDialect.class.getName());
configuration.setProperty("hibernate.show_sql", "true");
configuration.setProperty("hibernate.transaction.factory_class", "org.hibernate.transaction.JDBCTransactionFactory");
configuration.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.EhCacheProvider");
configuration.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.EhCacheProvider");
configuration.setProperty("hibernate.cache.use_query_cache", "true");
configuration.setProperty("hibernate.cache.use_second_level_cache", "true");

And this ehcache.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true">

<diskStore path="java.io.tmpdir"/>

<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="3"
timeToLiveSeconds="3"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>


In this configuration I want that each 3 seconds a new instance of each cached object is refreshed, but this isn´t hapenning. When I execute somethink this:

Object o = hibernateSession.get(clazz, id);

a line that show the SQL generated is shown:

Hibernate: select funcionali0_.FNC_CODIGO as FNC1_540_0_, funcionali0_.FNC_DESCRICAO as FNC2_540_0_, funcionali0_.FNC_NOME as FNC3_540_0_, funcionali0_.FNC_HASHCODE as FNC4_540_0_ from TBL_FUNCIONALIDADES funcionali0_ where funcionali0_.FNC_CODIGO=?

And I´d like that, after 3 seconds (like in the ehcache config) this line should be rewrited if I execute the same method (hibernateSession.get(clazz, id) ), but the SQL isn´t shown. Does anyone know what´s wrong with my cache config ?


Thanks in advance,

Sergio Stateri Jr.
sergio.stateri@globo.com


Top
 Profile  
 
 Post subject: Re: Cache never expires
PostPosted: Mon Dec 13, 2010 10:25 am 
Beginner
Beginner

Joined: Fri Nov 14, 2008 7:34 pm
Posts: 24
if it is in the same session, you get it from 1-st level cache


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.