Java 类javax.persistence.CacheStoreMode 实例源码

项目:OperatieBRP    文件:PartijRepositoryImpl.java   
@Override
public List<Partij> get() {
    final TypedQuery<Partij> query = em.createQuery("select p from Partij p where p.isActueelEnGeldig = true", Partij.class);
    query.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
    query.setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH);
    return query.getResultList();
}
项目:OperatieBRP    文件:LeveringsautorisatieRepositoryImpl.java   
private void zetDefaults(final Query query) {
    final Calendar cal = Calendar.getInstance();
    final int maandenTerug = -DATUM_EINDE_TERUG_MAAND;
    cal.add(Calendar.MONTH, maandenTerug);
    final Integer waarde = DatumUtil.vanDatumNaarInteger(cal.getTime());
    query.setParameter("dateinde", waarde);
    query.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
    query.setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH);
}
项目:litterbin    文件:TestBug463042.java   
@Test(threadPoolSize = 10, invocationCount = 100)
public void selectWithCaseAndHintShouldWorkInParallel() {
    EntityManager em = emf.createEntityManager();
    try {
        List result = em
            .createQuery("select case when d.id = 0 then 1 else 2 end from Dog d")
            .setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH)
            .getResultList();
    } finally {
        em.close();
    }
}
项目:litterbin    文件:TestBug463042.java   
@Test(threadPoolSize = 10, invocationCount = 100)
public void selectWithHintAndNoCaseShouldWorkInParallel() {
    EntityManager em = emf.createEntityManager();
    try {
        List result = em
            .createQuery("select d from Dog d")
            .setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH)
            .getResultList();
    } finally {
        em.close();
    }
}
项目:jpa-unit    文件:CleanupCacheIT.java   
@Before
public void configureEntityManager() {
    // These are defaults but put here for documentation purposes
    manager.setProperty("javax.persistence.cache.storeMode", CacheStoreMode.USE);
    manager.setProperty("javax.persistence.cache.retrieveMode", CacheRetrieveMode.USE);
}
项目:jpa-unit    文件:AbstractCleanupCacheTest.java   
@Before
public void configureEntityManager() {
    // These are defaults but put here for documentation purposes
    manager.setProperty("javax.persistence.cache.storeMode", CacheStoreMode.USE);
    manager.setProperty("javax.persistence.cache.retrieveMode", CacheRetrieveMode.USE);
}
项目:jpa-unit    文件:CleanupCacheIT.java   
@Before
public void configureEntityManager() {
    // These are defaults but put here for documentation purposes
    manager.setProperty("javax.persistence.cache.storeMode", CacheStoreMode.USE);
    manager.setProperty("javax.persistence.cache.retrieveMode", CacheRetrieveMode.USE);
}
项目:oldSyncopeIdM    文件:AbstractDAOImpl.java   
protected CacheStoreMode getCacheStoreMode() {
    return entityManager.getProperties().containsKey(CACHE_STORE_MODE)
            ? (CacheStoreMode) entityManager.getProperties().get(
            CACHE_STORE_MODE) : CacheStoreMode.BYPASS;
}
项目:oldSyncopeIdM    文件:AbstractDAOImpl.java   
protected void setCacheStoreMode(final CacheStoreMode storeMode) {
    if (storeMode != null) {
        entityManager.getProperties().
                put(CACHE_STORE_MODE, storeMode);
    }
}
项目:devicehive-java-server    文件:CacheConfig.java   
private CacheConfig(CacheRetrieveMode retrieveMode, CacheStoreMode storeMode) {
    this.retrieveMode = retrieveMode;
    this.storeMode = storeMode;
}
项目:devicehive-java-server    文件:CacheConfig.java   
public CacheStoreMode getStoreMode() {
    return storeMode;
}
项目:devicehive-java-server    文件:CacheConfig.java   
/**
 * get entities from cache
 */
public static CacheConfig get() {
    return new CacheConfig(CacheRetrieveMode.USE, CacheStoreMode.USE);
}
项目:devicehive-java-server    文件:CacheConfig.java   
/**
 * get entities from db and refresh cache
 */
public static CacheConfig refresh() {
    return new CacheConfig(CacheRetrieveMode.USE, CacheStoreMode.REFRESH);
}
项目:devicehive-java-server    文件:CacheConfig.java   
/**
 * bypass cache
 */
public static CacheConfig bypass() {
    return new CacheConfig(CacheRetrieveMode.BYPASS, CacheStoreMode.BYPASS);
}
项目:devicehive-java-server    文件:CacheHelper.java   
public static void cacheable(Query query) {
    query.setHint(CACHEBLE, true);
    query.setHint(RETRIEVE_MODE, CacheRetrieveMode.USE);
    query.setHint(STORE_MODE, CacheStoreMode.USE);
}