Example usage for org.hibernate.persister.entity AbstractEntityPersister getCacheAccessStrategy

List of usage examples for org.hibernate.persister.entity AbstractEntityPersister getCacheAccessStrategy

Introduction

In this page you can find the example usage for org.hibernate.persister.entity AbstractEntityPersister getCacheAccessStrategy.

Prototype

public EntityDataAccess getCacheAccessStrategy() 

Source Link

Usage

From source file:com.hmsinc.epicenter.model.AbstractJPARepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public <L extends T> List<L> getList(final Class<L> type) {

    Validate.notNull(type, "Type must be specified.");

    // Check to see if we should cache this entity first..
    boolean cache = true;

    if (!isOldHibernateVersion) {
        final ClassMetadata metadata = ((Session) entityManager.getDelegate()).getSessionFactory()
                .getClassMetadata(type);
        if (metadata instanceof AbstractEntityPersister) {
            final AbstractEntityPersister p = (AbstractEntityPersister) metadata;
            if (p.getCacheAccessStrategy() == null) {
                cache = false;/*from w w  w  .j a v  a  2s .  c o m*/
            }
        }
    }
    return ModelUtils.criteriaQuery(entityManager, type).setCacheable(cache).list();

}