HibernateDao的全部操作

package com.wmi.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wmi.dao.AllDao;

public class AllDaoImpl extends HibernateDaoSupport implements AllDao {
   
   
    public void delete(Object o) throws Exception {
        // TODO Auto-generated method stub
        this.getHibernateTemplate().delete(o);

    }

    public List qurey(final String hql, int pageno, final int pageSize) throws Exception {
        // TODO Auto-generated method stub
        final int fir=(pageno-1)*pageSize;
        List obj=this.getHibernateTemplate().executeFind(new HibernateCallback(){

            public Object doInHibernate(Session session)
                    throws HibernateException, SQLException {
                // TODO Auto-generated method stub
                List  oop=session.createQuery(hql).setFirstResult(fir).setMaxResults(pageSize).list();
                return oop;
            }
           
        });
        return obj;
    }
   

    public Object qurey(String hql,String name) throws Exception {
        List obj=this.getHibernateTemplate().findByExample(name,hql);
        return obj;
    }

    public void save(Object o) throws Exception {
        // TODO Auto-generated method stub
        this.getHibernateTemplate().save(o);
    }

    public void update(Object o) throws Exception {
        // TODO Auto-generated method stub
        this.getHibernateTemplate().update(o);
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值