Hibernate Cache with select count

3

Hello

I have a JPQL query, with count :

public Long quantidadeFaturasAbertasAssinante(Integer idAssin){     
   return manager.createQuery("select count(f) from Fatura f where f.dataLiquidacao IS NULL and f.assinante.id = :ass", Long.class)
            .setParameter("ass", idAssin)                
            .getSingleResult();    

}

When run the first time after starting tomcat, it returns the correct value. So I change some direct settlement date in the bank, but the value always remains the same until I restart tomcat.

It is as if it were cached, but I have already cleared the hibernate cache and it does not change. Any ideas?

I'm using version 4.3.8 of Hibernate, I've tried switching to 4.3.11 and it's no use. I'm using with JSF primefaces and CDI.

    
asked by anonymous 11.10.2016 / 21:06

1 answer

0

One possible answer to your problem is whether the Query Caching is enabled:

hibernate.cache.use_query_cache = true

This setting creates a cache using the query% and% of the query and the passed parameters. So when these two information matches what is already in the cache, Hibernate returns the ready result straight from the cache, without querying the database.

This would explain why your changes to the database do not reflect in the application.

    
24.09.2018 / 17:22