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);
    }

}

你可能感兴趣的:(exception,object,String,list,session,oop)