views:

51

answers:

1

This is how my entity look like

@Entity
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)   

@Table(name = "TestPojoOnly")
@NamedQueries({@NamedQuery(name = "TestPojoOnly.findAll", query = "SELECT h FROM TestPojoOnly h"), @NamedQuery(name = "TestPojoOnly.findById", query = "SELECT h FROM TestPojoOnly h WHERE h.id = :id"), @NamedQuery(name = "TestPojoOnly.findByCategoryname", query = "SELECT h FROM TestPojoOnly h WHERE h.categoryname = :categoryname")})
public class TestPojoOnly implements Serializable {

my ehcache.xml

<cache name="com.package.model.TestPojoOnly"
    maxElementsInMemory="200"
    eternal="false"
    overflowToDisk="false"
    timeToIdleSeconds="0"
    timeToLiveSeconds="0"
/>

Q. I already set time to Zero and eternal to false, but when i try load entity from db. it still get from cache. time=0 that mean no cache right? did i miss out something?

ref: my appcontex.xml at http://www.copypastecode.com/16833/

+2  A: 

timeToIdleSeconds and timeToLiveSeconds both treat zero as infinity. It wouldn't cut and paste properly from my iPhone, but if you do a find on the the ehcache configuration doc here for timeToLiveSeconds it says "A value of 0 means that an Element can live for infinity."

Benjamin Cox
bingo! thanks mate
cometta