sys用户表dao.java

来自「医院信息系统(Hospital Information System」· Java 代码 · 共 179 行

JAVA
179
字号
package hospital.Model;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Criteria;
import org.hibernate.criterion.Example;

/**
 * Data access object (DAO) for domain model class Sys用户表.
 * @see hospital.Model.Sys用户表
 * @author MyEclipse - Hibernate Tools
 */
public class Sys用户表DAO extends BaseHibernateDAO {

    private static final Log log = LogFactory.getLog(Sys用户表DAO.class);

	//property constants
	public static final String _用户名称 = "用户名称";
	public static final String _用户密码 = "用户密码";
	public static final String _密码确认 = "密码确认";
	public static final String _真实姓名 = "真实姓名";
	public static final String _家庭住址 = "家庭住址";

    
    public void save(Sys用户表 transientInstance) {
        log.debug("saving Sys用户表 instance");
        try {
            getSession().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }
    
	public void delete(Sys用户表 persistentInstance) {
        log.debug("deleting Sys用户表 instance");
        try {
            getSession().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }
    
    public Sys用户表 findById( java.lang.Integer id) {
        log.debug("getting Sys用户表 instance with id: " + id);
        try {
            Sys用户表 instance = (Sys用户表) getSession()
                    .get("hospital.Model.Sys用户表", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
    
    
    public List findByExample(Sys用户表 instance) {
        log.debug("finding Sys用户表 instance by example");
        try {
            List results = getSession()
                    .createCriteria("hospital.Model.Sys用户表")
                    .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;
        }
    }    
    
    public List findByProperty(String propertyName, Object value) {
      log.debug("finding Sys用户表 instance with property: " + propertyName
            + ", value: " + value);
      try {
         String queryString = "from Sys用户表 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 findUserByUserName_Password(String userName, String userPassword) {
      log.debug("from Sys用户表 as model where model.用户名称= "+userName+" and model.用户密码= "+userPassword);
      try {
         String queryString = "from Sys用户表 as model where model.用户名称= ? and model.用户密码= ?";
         Query queryObject = getSession().createQuery(queryString);
		 queryObject.setParameter(0, userName);
		 queryObject.setParameter(1, userPassword);
		 return queryObject.list();
      } catch (RuntimeException re) {
         log.error("find by property name failed", re);
         throw re;
      }
	}
    
    public List findData(String tableName){
    	//log.debug("from Sys用户表 as model where model.用户名称= "+userName+" and model.用户密码= "+userPassword);
        try {
        	Query q=getSession().createQuery("select s.姓名, s.性别 from 患者信息表 s");
        	q.setFirstResult(0);
        	q.setMaxResults(5);
        	List list=q.list();
        	//Criteria criteria=getSession().createCriteria(患者信息表.class);
        	//List list=criteria.setFirstResult(0).setMaxResults(5).list();
        	return list;
        } catch (RuntimeException re) {
           log.error("find by property name failed", re);
           throw re;
        }
    }
    
    //Criteria criteria=
	public List findBy用户名称(Object 用户名称) {
		return findByProperty(_用户名称, 用户名称);
	}
	
	public List findBy用户密码(Object 用户密码) {
		return findByProperty(_用户密码, 用户密码);
	}
	
	public List findBy密码确认(Object 密码确认) {
		return findByProperty(_密码确认, 密码确认);
	}
	
	public List findBy真实姓名(Object 真实姓名) {
		return findByProperty(_真实姓名, 真实姓名);
	}
	
	public List findBy家庭住址(Object 家庭住址) {
		return findByProperty(_家庭住址, 家庭住址);
	}
	
    public Sys用户表 merge(Sys用户表 detachedInstance) {
        log.debug("merging Sys用户表 instance");
        try {
            Sys用户表 result = (Sys用户表) getSession()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(Sys用户表 instance) {
        log.debug("attaching dirty Sys用户表 instance");
        try {
            getSession().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
    
    public void attachClean(Sys用户表 instance) {
        log.debug("attaching clean Sys用户表 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 + =
减小字号Ctrl + -
显示快捷键?