/**
* . 分页查询 BY HQL
*
* @param queryString :hql语句
* @return list
* @author 梁文敏
**/
public List findByHqlByLimit(String queryString,int frist,int end) {
LOG.debug("finding by hql:" + queryString);
List list = null;
try {
Query query = em.createQuery(queryString).setFirstResult(frist).setMaxResults(end);
list = query.getResultList();
} catch (RuntimeException re) {
LOG.error("find by hql failed", re);
throw re;
}
return list;
}
缓存使用
String cacheKey = "ZYZS_TEAM_ORG_DETAIL_" + orgDetailVo.getOrgId();
result = (RetResult<OrgTeamStatDetailDto>) CacheManager.getInstance().getCacheDataByKey(cacheKey);
if(result==null){
result = orgMergeService.orgTeamStatDetail(orgDetailVo);
CacheManager.getInstance().putCache(cacheKey, result, 30);
}
缓存方法 import java.util.concurrent.TimeUnit;
package com.zhongkai.jupiter.cache;
import java.util.concurrent.TimeUnit;
public class CacheManager {
private static ICacheManager iCacheManager = null;
static public ICacheManager getInstance() {
if (iCacheManager == null) {
iCacheManager = new CacheManagerImpl();
CacheListener cacheListener = new CacheListener(iCacheManager);
cacheListener.startListen();
}
return iCacheManager;
}
public static void main(String[] args) {
CacheManager.getInstance().putCache("11111", "333333", 1);
System.out.println(CacheManager.getInstance().getCacheDataByKey("11111"));
try {
TimeUnit.SECONDS.sleep(120);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(CacheManager.getInstance().getCacheDataByKey("11111"));
}
}