Example usage for org.hibernate CacheMode NORMAL

List of usage examples for org.hibernate CacheMode NORMAL

Introduction

In this page you can find the example usage for org.hibernate CacheMode NORMAL.

Prototype

CacheMode NORMAL

To view the source code for org.hibernate CacheMode NORMAL.

Click Source Link

Document

The session may read items from the cache, and add items to the cache.

Usage

From source file:org.yamj.core.database.dao.StagingDao.java

License:Open Source License

public List<StageFile> findStageFiles(FileType fileType, String searchName, String searchExtension,
        Library library) {//w ww  . j av  a2s. com
    StringBuilder sb = new StringBuilder();
    sb.append("SELECT distinct sf ");
    sb.append("FROM StageFile sf ");
    if (library != null) {
        sb.append("JOIN sf.stageDirectory sd ");
    }
    sb.append("WHERE sf.fileType=:fileType ");
    sb.append("AND lower(sf.baseName)=:searchName ");
    if (searchExtension != null) {
        sb.append("AND lower(sf.extension)=:searchExtension ");
    }
    if (library != null) {
        sb.append("AND sd.library=:library ");
    }
    sb.append("AND sf.status != :duplicate ");
    sb.append("AND sf.status != :deleted ");

    Query query = currentSession().createQuery(sb.toString());
    query.setParameter("fileType", fileType);
    query.setString("searchName", searchName.toLowerCase());
    if (searchExtension != null) {
        query.setString("searchExtension", searchExtension.toLowerCase());
    }
    if (library != null) {
        query.setParameter("library", library);
    }
    query.setParameter("duplicate", StatusType.DUPLICATE);
    query.setParameter("deleted", StatusType.DELETED);
    query.setCacheable(true);
    query.setCacheMode(CacheMode.NORMAL);
    return query.list();
}

From source file:org.yamj.core.database.dao.StagingDao.java

License:Open Source License

public List<StageFile> findVideoStageFiles(Artwork artwork) {
    StringBuilder sb = new StringBuilder();
    sb.append("SELECT distinct sf ");

    long id;/*w ww. j a  va  2s  .  c  o  m*/
    if (artwork.getSeries() != null) {
        id = artwork.getSeries().getId();
        sb.append("FROM Series ser ");
        sb.append("JOIN ser.seasons sea ");
        sb.append("JOIN sea.videoDatas vd ");
        sb.append("JOIN vd.mediaFiles mf ");
        sb.append("JOIN mf.stageFiles sf ");
        sb.append("WHERE sea.id=:id ");
    } else if (artwork.getSeason() != null) {
        id = artwork.getSeason().getId();
        sb.append("FROM Season sea ");
        sb.append("JOIN sea.videoDatas vd ");
        sb.append("JOIN vd.mediaFiles mf ");
        sb.append("JOIN mf.stageFiles sf ");
        sb.append("WHERE sea.id=:id ");
    } else {
        id = artwork.getVideoData().getId();
        sb.append("FROM VideoData vd ");
        sb.append("JOIN vd.mediaFiles mf ");
        sb.append("JOIN mf.stageFiles sf ");
        sb.append("WHERE vd.id=:id ");
    }
    sb.append("AND sf.fileType=:fileType ");
    sb.append("AND sf.status != :deleted ");

    Query query = currentSession().createQuery(sb.toString());
    query.setLong("id", id);
    query.setParameter("fileType", FileType.VIDEO);
    query.setBoolean("extra", Boolean.FALSE);
    query.setParameter("deleted", StatusType.DELETED);
    query.setCacheable(true);
    query.setCacheMode(CacheMode.NORMAL);
    return query.list();
}

From source file:org.yes.cart.dao.impl.GenericDAOHibernateImpl.java

License:Apache License

/**
 * {@inheritDoc}/*from   w w w  . j  a  v a2s  .c o m*/
 */
@SuppressWarnings("unchecked")
public List<T> findByNamedQueryCached(final String namedQueryName, final Object... parameters) {
    Query query = sessionFactory.getCurrentSession().getNamedQuery(namedQueryName);
    query.setCacheable(true);
    query.setCacheMode(CacheMode.NORMAL);
    setQueryParameters(query, parameters);
    return query.list();
}

From source file:se.dibbler.backend.dao.bean.IndexDaoBean.java

public void reIndex(Class clazz) {
    Session session = (Session) em.getDelegate();
    FullTextSession fullTextSession = Search.getFullTextSession(session);
    try {//  w w  w. jav a2 s.  c  o m
        fullTextSession.createIndexer(clazz).batchSizeToLoadObjects(BATCH_SIZE).cacheMode(CacheMode.NORMAL)
                .threadsToLoadObjects(5).threadsForSubsequentFetching(20).startAndWait();
    } catch (InterruptedException ex) {
        Logger.getLogger(IndexDaoBean.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:sql.support.ExecutionContextConversionTestImpl.java

License:LGPL

@Override
public CacheMode getCacheMode() {
    return CacheMode.NORMAL;
}