SortHibernateImpl.java
上传用户:yunfeng252
上传日期:2022-07-23
资源大小:12403k
文件大小:1k
源码类别:
Jsp/Servlet
开发平台:
Java
- package org.yufeng.dao.hibernate;
- import java.util.List;
- import org.hibernate.Query;
- import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
- import org.yufeng.dao.ISortDao;
- import org.yufeng.domains.Sort;
- import org.yufeng.service.ISortServiceDao;
- import org.yufeng.utils.AppContext;
- public class SortHibernateImpl extends HibernateDaoSupport implements ISortDao {
- public List browseSort(){
- return this.getHibernateTemplate().find("From Sort a order by a.so_id");
- }
- public Sort loadSort(Integer id){
- return (Sort) this.getHibernateTemplate().get(Sort.class, id);
- }
- public boolean delSort(Sort sort){
- boolean flag = false;
- try {
- this.getHibernateTemplate().delete(sort);
- flag = true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return flag;
- }
- public boolean addSort(Sort sort){
- boolean flag = false;
- try {
- this.getHibernateTemplate().save(sort);
- flag = true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return flag;
- }
- public boolean updateSort(String so_name,String edit_name){
- boolean flag = false;
- try {
- Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("update Sort set so_name=:edit_name where so_name=:so_name");
- query.setString("so_name", so_name);
- query.setString("edit_name", edit_name);
- query.executeUpdate();
- flag = true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return flag;
- }
- }