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

📄 roledao.java

📁 一个OA系统
💻 JAVA
字号:
package com.zhou.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.criterion.Example;

import com.zhou.po.Role;

/**
 * Data access object (DAO) for domain model class Role.
 * 
 * @see com.zhou.po.Role
 * @author MyEclipse Persistence Tools
 */

public class RoleDAO extends BaseHibernateDAO implements IRoleDAO {
	private static final Log log = LogFactory.getLog(RoleDAO.class);

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#save(com.zhou.po.Role)
	 */
	public void save(Role transientInstance) {
		log.debug("saving Role instance");
		try {
			getSession().beginTransaction().begin();
			getSession().save(transientInstance);
			getSession().beginTransaction().commit();
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#delete(com.zhou.po.Role)
	 */
	public void delete(Role persistentInstance)throws Exception {
		log.debug("deleting Role instance");
			System.out.print("...bb");
			try {
				getSession().delete(persistentInstance);
			} catch (Exception e) {
				
				System.out.print("fffffffffffffff");
				System.out.print(e.getMessage());
			}
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#findById(java.lang.Long)
	 */
	public Role findById(java.lang.Long id) {
		log.debug("getting Role instance with id: " + id);
		try {
			Role instance = (Role) getSession().get("com.zhou.po.Role", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}


	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#findByExample(com.zhou.po.Role)
	 */
	public List findByExample(Role instance) {
		log.debug("finding Role instance by example");
		try {
			List results = getSession().createCriteria("com.zhou.po.Role").add(
					Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#findByProperty(java.lang.String, java.lang.Object)
	 */
	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Role instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Role as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	public List findByAll() {
		try {
			String queryString = "from Role as model";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#findByRolename(java.lang.Object)
	 */
	public List findByRolename(Object rolename) {
		return findByProperty(ROLENAME, rolename);
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#findByJid(java.lang.Object)
	 */
	public List findByJid(Object jid) {
		return findByProperty(JID, jid);
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#findByJremark(java.lang.Object)
	 */
	public List findByJremark(Object jremark) {
		return findByProperty(JREMARK, jremark);
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#merge(com.zhou.po.Role)
	 */
	public Role merge(Role detachedInstance) {
		log.debug("merging Role instance");
		try {
			Role result = (Role) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#attachDirty(com.zhou.po.Role)
	 */
	public void attachDirty(Role instance) {
		log.debug("attaching dirty Role instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.zhou.dao.IRoleDAO#attachClean(com.zhou.po.Role)
	 */
	public void attachClean(Role instance) {
		log.debug("attaching clean Role instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}

⌨️ 快捷键说明

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