-->
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: Lost grip of cache
PostPosted: Mon Oct 19, 2015 5:53 am 
Newbie

Joined: Wed Aug 07, 2013 11:54 am
Posts: 5
Hi there,

I can't seem to setup EhCache 2.10.0 properly with Hibernate 4.3.1. Have followed many tutorials but I am not getting the expected outcome.

At first I wasn't caching at all, but recently many unexpected things have arosen which pressumably point to a wrong caching setting. My problem is that in my application at certain ocassions some entities are not persisted in the database. After checking code execution and seeing nothing was wrong with the code, we checked the database, and it was fine, changes were comitted successfully. But then when loading the same object in the gui, changes aren't updated, and shows and old version of it. Seems caching problems isn't it? Bear in mind that everytime I edit an object a start and commit a new different transaction (app managed though, not JTA).

So I am trying EhCache, but am getting the same results.... something has to be wrong with it. Can anybody point any hints out?

Here are my setup files.

Code:
<?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/ehcache" />

    <defaultCache maxEntriesLocalHeap="10000" eternal="false"
        timeToIdleSeconds="5" timeToLiveSeconds="5" diskSpoolBufferSizeMB="30"
        maxEntriesLocalDisk="10000000" diskExpiryThreadIntervalSeconds="120"
        memoryStoreEvictionPolicy="LRU" statistics="true">
        <persistence strategy="localTempSwap" />
    </defaultCache>
    <cache name="com.sofia.model.reports.flexreports.FlexReport" maxEntriesLocalHeap="50" eternal="false"
        timeToIdleSeconds="1" timeToLiveSeconds="1">
       
    </cache>


</ehcache>


As a start, I set very low timeToLive and timeToIdle values, to force cache deletion. I want to ensure I get the freshest data.

And persistence.xml (yes I still work with legacy files from the previous persistence provider)

Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="SofiaPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    ...
    <class>com.sofia.model.reports.flexreports.FlexReport</class>
   ...
    <validation-mode>NONE</validation-mode>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/dbname"/>
      <property name="javax.persistence.jdbc.password" value="dbpass"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.user" value="appuser"/>
     
      <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider"/>
      <property name="hibernate.cache.use_second_level_cache" value="true" />
      <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory" />
   
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
      <property name="hibernate.connection.release_mode" value="on_close"/>
      <property name="hibernate.show_sql" value="false"/>
     
     
     
     
    </properties>


Regards and many thanks in advance.

Carlos Conti.


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.