本文整理汇总了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());
}
}
示例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());
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}