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

📄 activitydao.java

📁 关于ssh的整合,希望对大家有帮助
💻 JAVA
字号:
package crm.dao.cst;

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 crm.entity.cst.ActivityEntity;

/**
 * Data access object (DAO) for domain model class ActivityEntity.
 * 
 * @see crm.entity.cst.ActivityEntity
 * @author MyEclipse Persistence Tools
 */

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

	// property constants
	public static final String ATV_CUST_NAME = "atvCustName";

	public static final String ATV_PLACE = "atvPlace";

	public static final String ATV_TITLE = "atvTitle";

	public static final String ATV_DESC = "atvDesc";

	protected void initDao() {
		// do nothing
	}

	public List findAll(String id)
	{
		Session session=this.getSession();
		String hql="select activity from ActivityEntity as activity  inner join activity.cstCustomer as cust where cust.custNo=?";
		Query query=session.createQuery(hql);
		query.setString(0, id);
		return query.list();
	}
	
	public void save(ActivityEntity transientInstance) {
		log.debug("saving ActivityEntity instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

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

	/**
	 * 删除方法(根据id删除)
	 */
	public void delete(int id)
	{
		long lid=id;    //将int型转换成long型
		this.delete(this.findById(lid));
	}
	public ActivityEntity findById(java.lang.Long id) {
		log.debug("getting ActivityEntity instance with id: " + id);
		try {
			ActivityEntity instance = (ActivityEntity) getHibernateTemplate()
					.get("crm.entity.cst.ActivityEntity", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

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

	public List findByAtvPlace(Object atvPlace) {
		return findByProperty(ATV_PLACE, atvPlace);
	}

	public List findByAtvTitle(Object atvTitle) {
		return findByProperty(ATV_TITLE, atvTitle);
	}

	public List findByAtvDesc(Object atvDesc) {
		return findByProperty(ATV_DESC, atvDesc);
	}

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

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

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

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

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

⌨️ 快捷键说明

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