⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 specialdaoimpl.java

📁 are are are are are are are are are are are are
💻 JAVA
字号:
/* * SpecialDaoImpl.java * * Created on 2006年5月20日, 下午9:19 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package enova.orm.hibernate.daoImpl;import enova.dao.*;import enova.pojo.*;import java.util.*;import org.hibernate.*;import enova.util.*;/** * * @author vlinux */public class SpecialDaoImpl implements SpecialDao{    public Special getId(Integer id) throws DataAccessException{        try{            Session session = HibernateUtil.currentSession();            List list = session.createQuery("from Special where id=:id").setParameter("id",id).list();            return list.isEmpty()?null:(Special)list.get(0);        }catch(HibernateException he){            throw new DataAccessException(he.toString());        }finally{            HibernateUtil.closeSession();        }    }        public void updateOrInsert(Special special) throws RecordExistException, DataAccessException{        try{            Session session = HibernateUtil.currentSession();            if( special.getId()==null ){                List list = session.createQuery("from Special where name=:name and DEPARTMENT_ID=:departmentId")                        .setParameter("name",special.getName())                        .setParameter("departmentId",special.getDepartment().getId())                        .list();                if( !list.isEmpty() )                    throw new RecordExistException();            }            Transaction tran = session.beginTransaction();            session.saveOrUpdate(special);            tran.commit();        }catch(HibernateException he){            throw new DataAccessException(he.toString());        }finally{            HibernateUtil.closeSession();        }    }        public void delete(Integer id) throws DataAccessException{        try{            Session session = HibernateUtil.currentSession();            Transaction tran = session.beginTransaction();            session.createQuery("delete from Special where id=:id")                    .setParameter("id",id)                    .executeUpdate();            tran.commit();        }catch(HibernateException he){            throw new DataAccessException(he.toString());        }finally{            HibernateUtil.closeSession();        }    }        public List getByDepartmentId(Integer departmentId) throws DataAccessException{        try{            Session session = HibernateUtil.currentSession();            return session.createQuery("from Special where DEPARTMENT_ID=:departmentId")                    .setParameter("departmentId",departmentId)                    .list();        }catch(HibernateException he){            throw new DataAccessException(he.toString());        }finally{            HibernateUtil.closeSession();        }    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -