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

📄 roominfodao.java

📁 有关医院方向的开发
💻 JAVA
字号:
package com.woyi.dao;
// default package

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.woyi.dto.HotelInfo;
import com.woyi.dto.RoomInfo;
import com.woyi.page.PageInfo;
import com.woyi.page.Pagination;

/**
 * Data access object (DAO) for domain model class RoomInfo.
 * @see .RoomInfo
  * @author MyEclipse Persistence Tools 
 */

public class RoomInfoDAO extends HibernateDaoSupport  {
    private static final Log log = LogFactory.getLog(RoomInfoDAO.class);
	//property constants
	public static final String ROOMS_NAME = "roomsName";
	public static final String ROOMSTABLEID = "roomstableid";
	public static final String ROOMS_SIZE = "roomsSize";
	public static final String HOTELFLOOR = "hotelfloor";
	public static final String HOTELTYPE = "hoteltype";
	public static final String OPTRID = "optrid";
	public static final String REMARK = "remark";


	
	private Pagination pageInfo;
	
	
	public Pagination getPageInfo() {
		return pageInfo;
	}

	public void setPageInfo(Pagination pageInfo) {
		this.pageInfo = pageInfo;
	}

	protected void initDao() {
		//do nothing
	}
    

    
    public boolean save(RoomInfo transientInstance) {
        log.debug("saving HotelInfo instance");
        boolean isflag = false;
        try {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
            isflag = true;
            return isflag;
        } catch (RuntimeException re) {
            log.error("save failed", re);
            return isflag;
            
        }
    }
    
	public boolean delete(RoomInfo persistentInstance) {
        log.debug("deleting RoomInfo instance");
        boolean isflag = false;
        try {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
            isflag = true;
            return isflag;
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            return isflag;
        }
    }
	
    
    public RoomInfo findById( java.lang.Integer id) {
        log.debug("getting RoomInfo instance with id: " + id);
        try {
            RoomInfo instance = (RoomInfo) getHibernateTemplate()
                    .get("RoomInfo", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
    
    
    public List findByExample(RoomInfo instance) {
        log.debug("finding RoomInfo instance by example");
        try {
            List results = getHibernateTemplate().findByExample(instance);
            log.debug("find by example successful, result size: " + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("find by example failed", re);
            throw re;
        }
    }    
    
    public List findByProperty(String propertyName, Object value) {
      log.debug("finding RoomInfo instance with property: " + propertyName
            + ", value: " + value);
      try {
         String queryString = "from RoomInfo as model where model." 
         						+ propertyName + "= ?";
		 return getHibernateTemplate().find(queryString, value);
      } catch (RuntimeException re) {
         log.error("find by property name failed", re);
         throw re;
      }
	}

	public List findByRoomsName(Object roomsName) {
		return findByProperty(ROOMS_NAME, roomsName);
	}
	
	public List findByRoomstableid(Object roomstableid) {
		return findByProperty(ROOMSTABLEID, roomstableid);
	}
	
	public List findByRoomsSize(Object roomsSize) {
		return findByProperty(ROOMS_SIZE, roomsSize);
	}
	
	public List findByHotelfloor(Object hotelfloor) {
		return findByProperty(HOTELFLOOR, hotelfloor);
	}
	
	public List findByHoteltype(Object hoteltype) {
		return findByProperty(HOTELTYPE, hoteltype);
	}
	
	public List findByOptrid(Object optrid) {
		return findByProperty(OPTRID, optrid);
	}
	
	public List findByRemark(Object remark) {
		return findByProperty(REMARK, remark);
	}
	

	public List findAll() {
		log.debug("finding all RoomInfo instances");
		try {
			String queryString = "from RoomInfo";
		 	return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
    public RoomInfo merge(RoomInfo detachedInstance) {
        log.debug("merging RoomInfo instance");
        try {
            RoomInfo result = (RoomInfo) getHibernateTemplate()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    
    public boolean attachDirty(RoomInfo instance) {
        log.debug("attaching dirty HotelInfo instance");
        boolean isflag = false;
        try {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
            isflag = true;
            return isflag;
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            return isflag;
        }
    }
    
    public void attachClean(RoomInfo instance) {
        log.debug("attaching clean RoomInfo instance");
        try {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
    
    
    /**
     * 查询客房信息
     * @param propertyName
     * @param value
     * @return
     */
    
    public PageInfo findRoomInfo(String roomname,String tableid,Integer roomsize,int pageno) {

        try {
           String queryString = "from RoomInfo as model where model.roomsId" 
           						 + "> 0";
         if (roomname != null && roomname.trim().length()>0){
        	  queryString =  queryString +" and model.roomsName like '%"+roomname+"%'";
          }else  if (roomsize !=null && roomsize >0){
        	  queryString =  queryString +" and model.roomsSize ="+roomsize;
          }else if (tableid != null && tableid.trim().length()>0){
        	  queryString =  queryString +" and model.roomstableid like '%"+tableid+"%'";
          } 
          
           String queryString1 = " select count(*) from RoomInfo as model where model.roomsId" 
				 + "> 0";
           if (roomname != null && roomname.trim().length()>0){
         	  queryString1 =  queryString1 +" and model.roomsName like '%"+roomname+"%'";
           }else  if (roomsize !=null && roomsize >0){
         	  queryString1 =  queryString1 +" and model.roomsSize ="+roomsize;
           }else if (tableid != null && tableid.trim().length()>0){
         	  queryString1 =  queryString1 +" and model.roomstableid like '%"+tableid+"%'";
           } 
			PageInfo pageInfo1 = pageInfo.page(pageno,10,queryString,queryString1);
  		    return pageInfo1;
        } catch (RuntimeException re) {
           log.error("find by property name failed", re);
           throw re;
        }
  	}
    
    
    /**
     * 查询单个包间信息
     * @param propertyName
     * @param value
     * @return
     */
    
    public List findSingleRoomInfo(Integer roomsId) {

        try {
           String queryString = "from RoomInfo as model where model.roomsId=" 
           						+ roomsId;
  		 return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re) {
           log.error("find by property name failed", re);
           throw re;
        }
  	}
    

	public static RoomInfoDAO getFromApplicationContext(ApplicationContext ctx) {
    	return (RoomInfoDAO) ctx.getBean("RoomInfoDAO");
	}
}

⌨️ 快捷键说明

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