posts - 0,  comments - 1,  trackbacks - 0
/**
     * TOP查询
     * 
@param  sql String
     * 
@param  top int
     * 
@return  List
     
*/
    
public  List findTop(String sql,  int  top) {
      HibernateTemplate ht 
=   this .getHibernateTemplate();
      ht.setMaxResults(top);
      
return  ht.find(sql);
    }

    
/**
     * 分页查询
     * 
@param  sql String
     * 
@param  firstRow int
     * 
@param  maxRow int
     * 
@return  List
     
*/
    
public  List findPage( final  String sql, final   int  firstRow, final   int  maxRow) {
      
return   this .getHibernateTemplate().executeFind( new  HibernateCallback(){
            
public  Object doInHibernate(Session session)  throws  SQLException,
                    HibernateException {
               Query q 
=  session.createQuery(sql);
               q.setFirstResult(firstRow);
               q.setMaxResults(maxRow);
               
return  q.list();
               }
        });      
    }
posted on 2008-03-27 17:25 火焰出林 阅读(148) 评论(0)  编辑  收藏 所属分类: J2EE

标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
 
 

推荐图书:
走出软件作坊》、《悟透JavaScript》、《Head First 设计模式
相关链接:
网站导航:



<2009年1月>
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

留言簿

随笔分类

文章分类(25)

文章档案(23)

新闻档案(8)

相册

最新随笔

搜索

  •  

最新评论