当前位置: 首页>>代码示例>>Java>>正文


Java Criteria.setCacheable方法代码示例

本文整理汇总了Java中org.hibernate.Criteria.setCacheable方法的典型用法代码示例。如果您正苦于以下问题:Java Criteria.setCacheable方法的具体用法?Java Criteria.setCacheable怎么用?Java Criteria.setCacheable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.Criteria的用法示例。


在下文中一共展示了Criteria.setCacheable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareCriteria

import org.hibernate.Criteria; //导入方法依赖的package包/类
/**
 * Prepare the given Criteria object, applying cache settings and/or
 * a transaction timeout.
 * @param criteria the Criteria object to prepare
 * @see #setCacheQueries
 * @see #setQueryCacheRegion
 */
protected void prepareCriteria(Criteria criteria) {
	if (isCacheQueries()) {
		criteria.setCacheable(true);
		if (getQueryCacheRegion() != null) {
			criteria.setCacheRegion(getQueryCacheRegion());
		}
	}
	if (getFetchSize() > 0) {
		criteria.setFetchSize(getFetchSize());
	}
	if (getMaxResults() > 0) {
		criteria.setMaxResults(getMaxResults());
	}

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null && sessionHolder.hasTimeout()) {
		criteria.setTimeout(sessionHolder.getTimeToLiveInSeconds());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:HibernateTemplate.java

示例2: prepareCriteria

import org.hibernate.Criteria; //导入方法依赖的package包/类
/**
 * Prepare the given Criteria object, applying cache settings and/or
 * a transaction timeout.
 * @param criteria the Criteria object to prepare
 * @see #setCacheQueries
 * @see #setQueryCacheRegion
 * @see SessionFactoryUtils#applyTransactionTimeout
 */
protected void prepareCriteria(Criteria criteria) {
	if (isCacheQueries()) {
		criteria.setCacheable(true);
		if (getQueryCacheRegion() != null) {
			criteria.setCacheRegion(getQueryCacheRegion());
		}
	}
	if (getFetchSize() > 0) {
		criteria.setFetchSize(getFetchSize());
	}
	if (getMaxResults() > 0) {
		criteria.setMaxResults(getMaxResults());
	}
	SessionFactoryUtils.applyTransactionTimeout(criteria, getSessionFactory());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:HibernateTemplate.java

示例3: getAllApp

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<Viapp> getAllApp() {
    List<Viapp> list = null;
    final Session session = sessions.openSession();
    try {
        Criteria cri = session.createCriteria(Viapp.class);
        cri.setCacheable(true);
        list = HibernateHelper.list(cri);
    } catch (Exception e) {
        logger.error("Exception", e);
    } finally {
        if (null != session) {
            session.close();
        }
    }
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:18,代码来源:AppDaoImpl.java

示例4: findAll

import org.hibernate.Criteria; //导入方法依赖的package包/类
/**
 * Return all objects related to the implementation of this DAO with no filter.
 * Use the session given.
 */
@SuppressWarnings("unchecked")
public List<T> findAll (Session s, Order... orders) {
	Criteria crit = s.createCriteria(getReferenceClass());
	if (orders != null) {
		for (Order order: orders) {
			if (order != null)
				crit.addOrder(order);
		}
	}
	crit.setCacheable(true);
	return (List<T>)crit.list();
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:17,代码来源:_BaseRootDAO.java

示例5: getPK

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public Integer getPK(Session sess, String marketName, int appIdOfMarketApp) {
    Criteria cri = sess.createCriteria(MarketApp.class);
    cri.setProjection(Projections.property("id"));
    cri.add(Restrictions.eq("appId", appIdOfMarketApp));
    cri.add(Restrictions.eq("marketName", marketName));
    cri.setCacheable(false);
    Object o = cri.uniqueResult();
    if (o != null) {
        return (Integer) o;
    }
    return null;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:14,代码来源:MarketAppDaoImpl.java

示例6: getByManyId

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public MarketApp getByManyId(Session sess, String marketName, Integer appIdOfMarket, int apkIdOfMarket) {
    Criteria cri = sess.createCriteria(MarketApp.class);
    if (appIdOfMarket != null && appIdOfMarket.intValue() > 0) {
        cri.add(Restrictions.eq("appId", appIdOfMarket));
    }
    cri.add(Restrictions.eq("apkId", apkIdOfMarket));
    cri.add(Restrictions.eq("marketName", marketName));
    cri.setCacheable(false);
    Object o = cri.uniqueResult();
    if (o != null) {
        return (MarketApp) o;
    }
    return null;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:16,代码来源:MarketAppDaoImpl.java

示例7: get

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public MarketApp get(Session session, String marketName, String pkname) {
    Criteria cri = session.createCriteria(MarketApp.class);
    cri.add(Restrictions.eq("pkname", pkname));
    cri.add(Restrictions.eq("marketName", marketName));
    cri.setCacheable(false);
    Object o = cri.uniqueResult();
    if (o != null) {
        return (MarketApp) o;
    }
    return null;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:13,代码来源:MarketAppDaoImpl.java

示例8: getPKName

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public MarketApp getPKName(EnumMarket enumMarket, String pkname) {
    Criteria cri = getSession().createCriteria(MarketApp.class);
    cri.add(Restrictions.eq("marketName", enumMarket.getName()));
    cri.add(Restrictions.eq("pkname", pkname));
    cri.setCacheable(false);
    Object o = cri.uniqueResult();
    if (o != null) {
        return (MarketApp) o;
    }
    return null;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:13,代码来源:MarketAppDaoImpl.java

示例9: getByName

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public Market getByName(Session session, String marketName) {
    Criteria cri = session.createCriteria(Market.class);
    cri.add(Restrictions.eq("marketName", marketName));
    cri.setCacheable(true);
    return (Market) cri.uniqueResult();
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:8,代码来源:MarketDaoImpl.java


注:本文中的org.hibernate.Criteria.setCacheable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。