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

📄 custinfodao.java

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

import java.util.Date;
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.CustInfo;
import com.woyi.page.PageInfo;
import com.woyi.page.Pagination;

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

public class CustInfoDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(CustInfoDAO.class);

	// property constants
	public static final String CUSTINFO_NAME = "custinfoName";

	public static final String CUSTID = "custid";

	public static final String CUSTNAME = "custname";

	public static final String CUSTTYPE = "custtype";

	public static final String CERTTYPE = "certtype";

	public static final String CERTNO = "certno";

	public static final String SVCNUM = "svcnum";

	public static final String ADDR = "addr";

	public static final String NEEDMINAREA = "needminarea";

	public static final String NEEDMAXAREA = "needmaxarea";

	public static final String LOWPRICE = "lowprice";

	public static final String UPPPRICE = "uppprice";

	public static final String NEEDHOUSETYPE = "needhousetype";

	public static final String NEEDHOUSEQULIT = "needhousequlit";

	public static final String OPTRID = "optrid";

	public static final String REMARK = "remark";

	private Pagination pageInfo;
	protected void initDao() {
		// do nothing
	}

	public boolean save(CustInfo transientInstance) {
		log.debug("saving CustInfo instance");
		try {
			getHibernateTemplate().save(transientInstance);
			
			log.debug("save successful");
			return true;
		} catch (RuntimeException re) {
			log.error("save failed", re);
			
			return false;
		}
	}

	public boolean delete(CustInfo persistentInstance) {
		log.debug("deleting CustInfo instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
			return true;
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			return false;
		}
	}

	public CustInfo findById(java.lang.Integer id) {
		log.debug("getting CustInfo instance with id: " + id);
		try {
			CustInfo instance = (CustInfo) getHibernateTemplate().get(
					"CustInfo", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(CustInfo instance) {
		log.debug("finding CustInfo 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 CustInfo instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from CustInfo 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 findByCustinfoName(Object custinfoName) {
		return findByProperty(CUSTINFO_NAME, custinfoName);
	}

	public List findByCustid(Object custid) {
		return findByProperty(CUSTID, custid);
	}

	public List findByCustname(Object custname) {
		return findByProperty(CUSTNAME, custname);
	}

	public List findByCusttype(Object custtype) {
		return findByProperty(CUSTTYPE, custtype);
	}

	public List findByCerttype(Object certtype) {
		return findByProperty(CERTTYPE, certtype);
	}

	public List findByCertno(Object certno) {
		return findByProperty(CERTNO, certno);
	}

	public List findBySvcnum(Object svcnum) {
		return findByProperty(SVCNUM, svcnum);
	}

	public List findByAddr(Object addr) {
		return findByProperty(ADDR, addr);
	}

	public List findByNeedminarea(Object needminarea) {
		return findByProperty(NEEDMINAREA, needminarea);
	}

	public List findByNeedmaxarea(Object needmaxarea) {
		return findByProperty(NEEDMAXAREA, needmaxarea);
	}

	public List findByLowprice(Object lowprice) {
		return findByProperty(LOWPRICE, lowprice);
	}

	public List findByUppprice(Object uppprice) {
		return findByProperty(UPPPRICE, uppprice);
	}

	public List findByNeedhousetype(Object needhousetype) {
		return findByProperty(NEEDHOUSETYPE, needhousetype);
	}

	public List findByNeedhousequlit(Object needhousequlit) {
		return findByProperty(NEEDHOUSEQULIT, needhousequlit);
	}

	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 CustInfo instances");
		try {
			String queryString = "from CustInfo";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public CustInfo merge(CustInfo detachedInstance) {
		log.debug("merging CustInfo instance");
		try {
			CustInfo result = (CustInfo) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public boolean attachDirty(CustInfo instance) {
		log.debug("attaching dirty CustInfo instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
			return true;
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			return false;
		}
	}

	public void attachClean(CustInfo instance) {
		log.debug("attaching clean CustInfo instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
	
	public static CustInfoDAO getFromApplicationContext(ApplicationContext ctx) {
		return (CustInfoDAO) ctx.getBean("CustInfoDAO");
	}
	/*
	 * 查询客户信息
	 */
	public PageInfo findCustInfo(String CustName,String certno, int pageno)
	{
		try{
			String queryString = "from CustInfo as model where model.custinfoId" 
					 + "> 0";
			
			if (CustName !=null && CustName.trim().length() >0){
			queryString =  queryString +" and model.custname like '%"+CustName+"%'";
			}  
			
			if ( certno !=null && certno.trim().length() >0){
				queryString =  queryString +" and model.certno ='"+certno+"'";
			}
			String queryString1 = " select count(*) from CustInfo as model where model.custinfoId" 
			+ "> 0";
			if (CustName !=null && CustName.trim().length() >0){
				queryString1 =  queryString1 +" and model.custname like '%"+CustName+"%'";
			}  
			if ( certno !=null && certno.trim().length() >0){
				queryString1 =  queryString1 +" and model.certno ='"+certno+"'";
			}
		//	getHibernateTemplate().find(queryString1);
			PageInfo pageInfo1 = pageInfo.page(pageno,10,queryString,queryString1);
		//	PageInfo pageInfo1 = new PageInfo();
  		    return pageInfo1;
			
		}
		catch (RuntimeException re) {
	           log.error("find by property name failed", re);
	           throw re;
	        }
	}
	/*
	 * 获取单个客户信息
	 */
    public List getSingleCust(Integer custinfoId) {

        try {
           String queryString = "from CustInfo as model where model.custinfoId=" 
           						+ custinfoId;
  		 return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re) {
           log.error("find by property name failed", re);
           throw re;
        }
  	}
    /*
     * 关联房源信息查询客户信息
     */
    public PageInfo querySmsCustInfo(String allname,String salestate,int pageno)
    {
        try {
         	PageInfo pageInfo1 = null;
	          String queryString = "  select a from UnionHouseInfo as b right outer  join b.custInfo as a  where a.custinfoId" 
	           						 + "> 0 ";
	          if (allname != null && allname.trim().length()>0)
	        	  queryString = queryString + " and b.allname like '%"+allname+"%'";
	          if(salestate != null && salestate.trim().length() > 0 && !"0".equals(salestate.trim()))
	        	  queryString = queryString + " and b.salestate = '"+salestate+"'";
	        
	          
	          String queryString1 = "select count(b) from UnionHouseInfo as b right outer  join b.custInfo as a where a.custinfoId" 
	        	  					+ "> 0  ";
	          
	          if (allname != null && allname.trim().length()>0)
	        	  queryString1 = queryString1 + " and b.allname like '%"+allname+"%'";
	          if(salestate != null && salestate.trim().length() > 0 && !"0".equals(salestate.trim()))
	        	  queryString1 = queryString1 + " and b.salestate = '"+salestate+"'";

	          pageInfo1 = pageInfo.page(pageno,20,queryString,queryString1);
		
  		    return pageInfo1;
        } catch (RuntimeException re) {
           log.error("find by property name failed", re);
           throw re;
        }
    	
    }
	public Pagination getPageInfo() {
		return pageInfo;
	}

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

⌨️ 快捷键说明

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