clientstatedao.java

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

JAVA
143
字号
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.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.crm.pojo.ClientState;

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

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

	// property constants
	public static final String CLIENT_STATE_NAME = "clientStateName";

	protected void initDao() {
		// do nothing
	}

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

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

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

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

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

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

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

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

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

⌨️ 快捷键说明

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