venditionchancedao.java

来自「一套自己原先在学校作的CRM,大家指点下」· Java 代码 · 共 286 行

JAVA
286
字号
package com.crm.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.crm.pojo.VenditionChance;

/**
 * Data access object (DAO) for domain model class VenditionChance.
 * 
 * @see com.crm.pojo.VenditionChance
 * @author MyEclipse Persistence Tools
 */

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

	// property constants
	public static final String CHANCE_SOURCE = "chanceSource";

	public static final String CHANCE_CLIENT_NAME = "chanceClientName";

	public static final String CHANCE_SUMMARY = "chanceSummary";

	public static final String CHANCE_LINKMAN = "chanceLinkman";

	public static final String CHANCE_LINKMAN_PHON = "chanceLinkmanPhon";

	public static final String CHANCE_DEPICT = "chanceDepict";

	public static final String CHANCE_USER = "chanceUser";

	public static final String CHANCE_FOUND_TIME = "chanceFoundTime";

	public static final String CHANCE_EMPLOYEE = "chanceEmployee";

	public static final String CHANCE_ASSIGN_TIME = "chanceAssignTime";

	public static final String CHANCE_STATE = "chanceState";

	protected void initDao() {
		// do nothing
	}

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

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

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

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

	public List findByChanceClientName(Object chanceClientName) {
		return findByProperty(CHANCE_CLIENT_NAME, chanceClientName);
	}

	public List findByChanceSummary(Object chanceSummary) {
		return findByProperty(CHANCE_SUMMARY, chanceSummary);
	}

	public List findByChanceLinkman(Object chanceLinkman) {
		return findByProperty(CHANCE_LINKMAN, chanceLinkman);
	}

	public List findByChanceLinkmanPhon(Object chanceLinkmanPhon) {
		return findByProperty(CHANCE_LINKMAN_PHON, chanceLinkmanPhon);
	}

	public List findByChanceDepict(Object chanceDepict) {
		return findByProperty(CHANCE_DEPICT, chanceDepict);
	}

	public List findByChanceUser(Object chanceUser) {
		return findByProperty(CHANCE_USER, chanceUser);
	}

	public List findByChanceFoundTime(Object chanceFoundTime) {
		return findByProperty(CHANCE_FOUND_TIME, chanceFoundTime);
	}

	public List findByChanceEmployee(Object chanceEmployee) {
		return findByProperty(CHANCE_EMPLOYEE, chanceEmployee);
	}

	public List findByChanceAssignTime(Object chanceAssignTime) {
		return findByProperty(CHANCE_ASSIGN_TIME, chanceAssignTime);
	}

	public List findByChanceState(Object chanceState) {
		return findByProperty(CHANCE_STATE, chanceState);
	}

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

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

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

	public void attachClean(VenditionChance instance) {
		log.debug("attaching clean VenditionChance instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	
	public List find(VenditionChance vc,int pageNo,int pageSize){
		String sql="from VenditionChance v where 1=1 and v.chanceEmployee='' ";
		Session s=this.getSessionFactory().openSession();
		if(!(vc.getChanceClientName()==null || vc.getChanceClientName().equals(""))){
			sql+=" and v.chanceClientName like '%"+vc.getChanceClientName()+"%'";
		}
		if(!(vc.getChanceLinkman()==null || vc.getChanceLinkman().equals(""))){
			sql+=" and v.chanceLinkman() like '%"+vc.getChanceLinkman()+"%'";
		}
		if(!(vc.getChanceSummary()==null || vc.getChanceSummary().equals(""))){
			sql+=" and v.chanceSummary like '%"+vc.getChanceSummary()+"%'";
		}
		sql+=" order by v.chanceId asc";
		Query query=s.createQuery(sql);
		int fri=pageSize*(pageNo-1);
		query.setFirstResult(fri);
		query.setMaxResults(pageSize);
		List list=query.list();
		s.close();
		return list;
	}
	public List findAll(VenditionChance vc){
		String sql="from VenditionChance v where 1=1 and v.chanceEmployee='' ";
		Session s=this.getSessionFactory().openSession();
		if(!(vc.getChanceClientName()==null || vc.getChanceClientName().equals(""))){
			sql+=" and v.chanceClientName like '%"+vc.getChanceClientName()+"%'";
		}
		if(!(vc.getChanceLinkman()==null || vc.getChanceLinkman().equals(""))){
			sql+=" and v.chanceLinkman like '%"+vc.getChanceLinkman()+"%'";
		}
		if(!(vc.getChanceSummary()==null || vc.getChanceSummary().equals(""))){
			sql+=" and v.chanceSummary like '%"+vc.getChanceSummary()+"%'";
		}
		sql+=" order by v.chanceId asc";
		System.out.println(sql);
		Query query=s.createQuery(sql);
		List list=query.list();
		s.close();
		return list;
	}
	public List findNot(VenditionChance vc,int pageNo,int pageSize){
		String sql="from VenditionChance v where 1=1 and v.chanceEmployee!='' ";
		Session s=this.getSessionFactory().openSession();
		if(!(vc.getChanceClientName()==null || vc.getChanceClientName().equals(""))){
			sql+=" and v.chanceClientName like '%"+vc.getChanceClientName()+"%'";
		}
		if(!(vc.getChanceLinkman()==null || vc.getChanceLinkman().equals(""))){
			sql+=" and v.chanceLinkman() like '%"+vc.getChanceLinkman()+"%'";
		}
		if(!(vc.getChanceSummary()==null || vc.getChanceSummary().equals(""))){
			sql+=" and v.chanceSummary like '%"+vc.getChanceSummary()+"%'";
		}
		sql+=" order by v.chanceId asc";
		Query query=s.createQuery(sql);
		int fri=pageSize*(pageNo-1);
		query.setFirstResult(fri);
		query.setMaxResults(pageSize);
		List list=query.list();
		s.close();
		return list;
	}
	public List findAllNot(VenditionChance vc){
		String sql="from VenditionChance v where 1=1 and v.chanceEmployee!='' ";
		Session s=this.getSessionFactory().openSession();
		if(!(vc.getChanceClientName()==null || vc.getChanceClientName().equals(""))){
			sql+=" and v.chanceClientName like '%"+vc.getChanceClientName()+"%'";
		}
		if(!(vc.getChanceLinkman()==null || vc.getChanceLinkman().equals(""))){
			sql+=" and v.chanceLinkman like '%"+vc.getChanceLinkman()+"%'";
		}
		if(!(vc.getChanceSummary()==null || vc.getChanceSummary().equals(""))){
			sql+=" and v.chanceSummary like '%"+vc.getChanceSummary()+"%'";
		}
		sql+=" order by v.chanceId asc";
		System.out.println(sql);
		Query query=s.createQuery(sql);
		List list=query.list();
		s.close();
		return list;
	}
	public static VenditionChanceDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (VenditionChanceDAO) ctx.getBean("VenditionChanceDAO");
	}
}

⌨️ 快捷键说明

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