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

📄 systemuserinfodao.java

📁 spring+Jsf+hibernate集成实例
💻 JAVA
字号:
package com.QualityTrack.subsystem.User.Dao;

import java.util.Date;
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.QualityTrack.subsystem.User.Bean.SystemUserInfo;
/**
 * A data access object (DAO) providing persistence and search support for
 * SystemUserInfo entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.QualityTrack.subsystem.User.Bean.SystemUserInfo
 * @author MyEclipse Persistence Tools
 */

public class SystemUserInfoDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(SystemUserInfoDAO.class);
	// property constants
	public static final String LOGIN_NAME = "loginName";
	public static final String USER_NAME = "userName";
	public static final String USER_PASSWORD = "userPassword";
	public static final String USER_SEX = "userSex";
	public static final String USER_CLASS = "userClass";
	public static final String USER_DEPT = "userDept";
	public static final String USER_TELL = "userTell";
	public static final String USER_HANDSET = "userHandset";
	public static final String USER_EMAIL = "userEmail";
	public static final String USER_ADDRESS = "userAddress";
	public static final String USER_LOGIN_IP = "userLoginIp";
	public static final String USER_GELATION = "userGelation";

	protected void initDao() {
		// do nothing
	}

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

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

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

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

	public List findByUserName(Object userName) {
		return findByProperty(USER_NAME, userName);
	}

	public List findByUserPassword(Object userPassword) {
		return findByProperty(USER_PASSWORD, userPassword);
	}

	public List findByUserSex(Object userSex) {
		return findByProperty(USER_SEX, userSex);
	}

	public List findByUserClass(Object userClass) {
		return findByProperty(USER_CLASS, userClass);
	}

	public List findByUserDept(Object userDept) {
		return findByProperty(USER_DEPT, userDept);
	}

	public List findByUserTell(Object userTell) {
		return findByProperty(USER_TELL, userTell);
	}

	public List findByUserHandset(Object userHandset) {
		return findByProperty(USER_HANDSET, userHandset);
	}

	public List findByUserEmail(Object userEmail) {
		return findByProperty(USER_EMAIL, userEmail);
	}

	public List findByUserAddress(Object userAddress) {
		return findByProperty(USER_ADDRESS, userAddress);
	}

	public List findByUserLoginIp(Object userLoginIp) {
		return findByProperty(USER_LOGIN_IP, userLoginIp);
	}

	public List findByUserGelation(Object userGelation) {
		return findByProperty(USER_GELATION, userGelation);
	}

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

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

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

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

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

⌨️ 快捷键说明

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