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

📄 humanfiledao.java

📁 hr伯乐管理系统!非常适合java学员做学习参考用!是用集成框架开发的Struts+hrbernet+Spring 开发的
💻 JAVA
字号:
package org.better.hr.dao;

import java.util.List;

import org.better.hr.comm.Util;
import org.better.hr.entity.HumanFile;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;



public class HumanFileDao extends BasicDao {
	
	
	/**
	 * 查询方法,根据hbm.xml中的<sql-query>中的查询语句进行查询
	 * @return 存放HumanFile对象的集合
	 */
	public List find(){
		List list = this.getHibernateTemplate().find("select max(f.hufId) from HumanFile f");
		return list;
	}
	
	/**
	 * 查询方法,重载
	 * @param condition 对象,该对象中设定了查询条件
	 * @return 存放HumanFile对象的集合
	 */
	public List find(final HumanFile condition)
	{
		return this.getHibernateTemplate().executeFind(
				new HibernateCallback()
				{
					public Object doInHibernate(Session s) throws HibernateException{
						Criteria c = s.createCriteria(HumanFile.class);
						if (null != condition)
						{
							if (!Util.isNullOrBlank(condition.getFirstKindName())) {
								c.add(Restrictions
										.like("firstKindName", condition.getFirstKindName(),MatchMode.ANYWHERE));
							}
							if (!Util.isNullOrBlank(condition.getSecondKindName())) {
								c.add(Restrictions
										.like("secondKindName", condition.getSecondKindName(),MatchMode.ANYWHERE));
							}
							if (!Util.isNullOrBlank(condition.getThirdKindName())) {
								c.add(Restrictions
										.like("thirdKindName", condition.getThirdKindName(),MatchMode.ANYWHERE));
							}
							if (!Util.isNullOrBlank(condition.getHumanMajorKindName())) {
								c.add(Restrictions
										.like("humanMajorKindName", condition.getHumanMajorKindName(),MatchMode.ANYWHERE));
							}
							if (!Util.isNullOrBlank(condition.getHunmaMajorName())) {
								c.add(Restrictions
										.like("hunmaMajorName", condition.getHunmaMajorName(),MatchMode.ANYWHERE));
							}
							if (!Util.isNullOrBlank(condition.getStr_startTime())) {
								c.add(Restrictions
										.ge("registTime", Util.parseDate(condition.getStr_startTime())));
							}
							if (!Util.isNullOrBlank(condition.getStr_endTime())) {
								c.add(Restrictions
										.le("registTime", Util.parseDate(condition.getStr_endTime())));
							}
							if(!Util.isNullOrBlank(condition.getCheckStatus())){
								c.add(Restrictions
										.eq("checkStatus", condition.getCheckStatus()));
							}
							if(!Util.isNullOrBlank(condition.getHumanFileStatus().toString())){
								c.add(Restrictions
										.eq("humanFileStatus", condition.getHumanFileStatus()));
							}
						}
						c.addOrder(Order.asc("hufId"));
						return c.list();
					}
				}
		);
	}
	
	/**
	 * 查询
	 * @param key 关键字
	 * @param delState 删除状态
	 * @return
	 */
	public List listByKey(String key,byte delState,byte chkState)
	{
		String sql = super.listByKey("HumanFile", key);
		sql += " and humanFileStatus = " + delState + " and checkStatus = " + chkState;
		
		return this.getHibernateTemplate().find(sql);
	}
}

⌨️ 快捷键说明

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