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

📄 cstlostdao.java

📁 做的是一个客户关系管理系统
💻 JAVA
字号:
package com.accp.dao;

import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * Data access object (DAO) for domain model class CstLost.
 * 
 * @see com.accp.dao.CstLost
 * @author MyEclipse Persistence Tools
 */

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

	// property constants
	public static final String LST_CUST_NAME = "lstCustName";

	public static final String LST_CUST_MANAGER_ID = "lstCustManagerId";

	public static final String LST_CUST_MANAGER_NAME = "lstCustManagerName";

	public static final String LST_DELAY = "lstDelay";

	public static final String LST_REASON = "lstReason";

	public static final String LST_STATUS = "lstStatus";

	protected void initDao() {
		// do nothing
	}

	public void save(CstLost transientInstance) {
		log.debug("saving CstLost instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(CstLost persistentInstance) {
		log.debug("deleting CstLost instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

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

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

	public List findByLstCustManagerId(Object lstCustManagerId) {
		return findByProperty(LST_CUST_MANAGER_ID, lstCustManagerId);
	}

	public List findByLstCustManagerName(Object lstCustManagerName) {
		return findByProperty(LST_CUST_MANAGER_NAME, lstCustManagerName);
	}

	public List findByLstDelay(Object lstDelay) {
		return findByProperty(LST_DELAY, lstDelay);
	}

	public List findByLstReason(Object lstReason) {
		return findByProperty(LST_REASON, lstReason);
	}

	public List findByLstStatus(Object lstStatus) {
		return findByProperty(LST_STATUS, lstStatus);
	}

	public List findAll() {
		log.debug("finding all CstLost instances");
		try {
			String queryString = "from CstLost";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

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

	public void attachDirty(CstLost instance) {
		log.debug("attaching dirty CstLost instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(CstLost instance) {
		log.debug("attaching clean CstLost instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
	
	public List findByLost(CstLost lost)
	{
		Session session = this.getSession();
		Criteria criteria = session.createCriteria(CstLost.class);
		if(lost != null)
		{
			if(lost.getLstCustName() != null && !lost.getLstCustName().equals(""))
			{
				criteria.add(Restrictions.like("lstCustName", lost.getLstCustName(),MatchMode.ANYWHERE));
			}
			if(lost.getLstCustManagerName() != null && !lost.getLstCustManagerName().equals(""))
			{
				criteria.add(Restrictions.like("lstCustManagerName", lost.getLstCustName(),MatchMode.ANYWHERE));
			}
			if(lost.getLstStatus() != null && !lost.getLstStatus().equals("0")){
				criteria.add(Restrictions.like("lstStatus",lost.getLstStatus()));
			}
		}
		return criteria.list();
	}

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

⌨️ 快捷键说明

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