rightsdao.java

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

JAVA
166
字号
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.Rights;

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

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

	// property constants
	public static final String RIGHT_PARENT_CODE = "rightParentCode";

	public static final String RIGHT_TEXT = "rightText";

	public static final String RIGHT_URL = "rightUrl";

	public static final String RIGHT_TIP = "rightTip";

	public static final String RIGHT_TYPE = "rightType";

	protected void initDao() {
		// do nothing
	}

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

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

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

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

	public List findByRightText(Object rightText) {
		return findByProperty(RIGHT_TEXT, rightText);
	}

	public List findByRightUrl(Object rightUrl) {
		return findByProperty(RIGHT_URL, rightUrl);
	}

	public List findByRightTip(Object rightTip) {
		return findByProperty(RIGHT_TIP, rightTip);
	}

	public List findByRightType(Object rightType) {
		return findByProperty(RIGHT_TYPE, rightType);
	}

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

	public Rights merge(Rights detachedInstance) {
		log.debug("merging Rights instance");
		try {
			Rights result = (Rights) getHibernateTemplate().merge(
					detachedInstance);
			super.getHibernateTemplate().getSessionFactory().openSession().beginTransaction().commit();
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

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

	public void attachClean(Rights instance) {
		log.debug("attaching clean Rights instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
	public static RightsDAO getFromApplicationContext(ApplicationContext ctx) {
		return (RightsDAO) ctx.getBean("RightsDAO");
	}
}

⌨️ 快捷键说明

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