Example usage for javax.persistence CacheRetrieveMode BYPASS

List of usage examples for javax.persistence CacheRetrieveMode BYPASS

Introduction

In this page you can find the example usage for javax.persistence CacheRetrieveMode BYPASS.

Prototype

CacheRetrieveMode BYPASS

To view the source code for javax.persistence CacheRetrieveMode BYPASS.

Click Source Link

Document

Bypass the cache: get data directly from the database.

Usage

From source file:org.syncope.core.persistence.dao.impl.AbstractDAOImpl.java

protected CacheRetrieveMode getCacheRetrieveMode() {
    return entityManager.getProperties().containsKey(CACHE_RETRIEVE_MODE)
            ? (CacheRetrieveMode) entityManager.getProperties().get(CACHE_RETRIEVE_MODE)
            : CacheRetrieveMode.BYPASS;
}

From source file:KitchenManagement.FoodDemandForecastingAndPlanning.FoodDemandForecastingAndPlanningBean.java

@Override
public SaleForecastEntity getSalesForecast(Long storeId, Long menuItemId, Long scheduleId) {
    System.out.println("getSalesForecast is called");
    try {/*from  w  ww.j a v a  2 s  . c om*/
        Query q = em.createQuery(
                "select sf from SaleForecastEntity sf where sf.menuItem.id = ?1 AND sf.store.id = ?2 AND sf.schedule.id = ?3")
                .setParameter(1, menuItemId).setParameter(2, storeId).setParameter(3, scheduleId);
        q.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
        if (!q.getResultList().isEmpty()) {
            return (SaleForecastEntity) q.getResultList().get(0);
        } else {
            return this.getSalesForecastLinearRegression(storeId, menuItemId, scheduleId);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return null;
}

From source file:com.hiperium.dao.common.generic.GenericDAO.java

/**
 * /*from ww  w. ja  va  2 s .co  m*/
 * @param id
 * @param lock
 * @param bypassCache
 * @return
 */
protected T findById(ID id, boolean lock, boolean bypassCache) {
    this.logger.debug("findById - START");
    T entity = null;
    if (bypassCache) {
        this.entityManager.setProperty(RETRIEVE_MODE, CacheRetrieveMode.BYPASS);
        this.entityManager.setProperty(STORE_MODE, CacheStoreMode.REFRESH);
        entity = this.entityManager.find(this.entityClass, id);
    } else {
        entity = this.entityManager.find(this.entityClass, id);
    }
    if (lock) {
        this.entityManager.lock(entity, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
    }
    this.logger.debug("findById - END");
    return entity;
}

From source file:com.hiperium.dao.common.generic.GenericDAO.java

/**
 * //from  w ww  .  ja  va 2s .  c o m
 * @param query
 */
private void setBypassCahe(Query query) {
    query.setHint(RETRIEVE_MODE, CacheRetrieveMode.BYPASS);
    query.setHint(STORE_MODE, CacheStoreMode.REFRESH);
}