Refresh collection / empty cache - using entity manager

139 views Asked by At

Hello guys I have pretty strange problem that I cannot resolve my code looks like this:

@Transactional
public List<ProductObject> readproductObjectes() {

    TypedQuery<ProductObject> query = em.createQuery("SELECT productObject FROM pl.allegroapp.classes.allegro.ProductObjectImpl productObject ORDER BY productObject.yourNewStyleId DESC", ProductObject.class);
    List<ProductObject> ProductObjectList =  query.getResultList();

    return query.getResultList();
}

After I edit some entities and reload them using this - there are no changes, I see changes on database etc but not in application. I tried many ways to "refresh" the data. I added this:

em.getEntityManagerFactory().getCache().evictAll();
em.setProperty("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
query.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);

Nothing of this worked for me.

0

There are 0 answers