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

📄 arrangementdao.java

📁 开源struts spring hibernate构架 实验室排课系统
💻 JAVA
字号:
package dao;

import java.util.Collections;
import java.util.Comparator;
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 service.ArrangeComparetor;
import vo.Arrangement;

/**
 * Data access object (DAO) for domain model class Arrangement.
 * 
 * @see vo.Arrangement
 * @author MyEclipse Persistence Tools
 */

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

	// property constants
	public static final String COURSE_NAME = "courseName";

	public static final String EXP_NAME = "expName";

	public static final String COURSE_PRO = "coursePro";

	public static final String PERIOD = "period";

	public static final String CLASSES = "classes";

	public static final String POPULATION = "population";

	public static final String WEEK_DAY = "weekDay";

	public static final String PERIOD_SEQ = "periodSeq";

	public static final String TECHER = "techer";

	public static final String EXP_ENVIRONMENT = "expEnvironment";

	public static final String PS = "ps";

	public static final String WEEK = "week";

	public static final String TERM = "term";

	public static final String YEAR = "year";

	public static final String APPLIER = "applier";

	public static final String IS_APPLIED = "isApplied";

	public static final String DATE = "date";

	public static final String WEIGHT = "weight";

	protected void initDao() {
		// do nothing
	}

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

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

	  public boolean update(Arrangement persistentInstance)   {   
		  // 修改 
		  this.getHibernateTemplate().update(persistentInstance);   
		  return true;   
		  }   
	
	public Arrangement findById(java.lang.Integer id) {
		log.debug("getting Arrangement instance with id: " + id);
		try {
			Arrangement instance = (Arrangement) getHibernateTemplate().get(
					"vo.Arrangement", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Arrangement instance) {
		log.debug("finding Arrangement instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			Comparator comp=new ArrangeComparetor();
			Collections.sort(results, comp);
			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 Arrangement instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Arrangement 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 findByCourseName(Object courseName) {
		return findByProperty(COURSE_NAME, courseName);
	}

	public List findByExpName(Object expName) {
		return findByProperty(EXP_NAME, expName);
	}

	public List findByCoursePro(Object coursePro) {
		return findByProperty(COURSE_PRO, coursePro);
	}

	public List findByPeriod(Object period) {
		return findByProperty(PERIOD, period);
	}

	public List findByClasses(Object classes) {
		return findByProperty(CLASSES, classes);
	}

	public List findByPopulation(Object population) {
		return findByProperty(POPULATION, population);
	}

	public List findByWeekDay(Object weekDay) {
		return findByProperty(WEEK_DAY, weekDay);
	}

	public List findByPeriodSeq(Object periodSeq) {
		return findByProperty(PERIOD_SEQ, periodSeq);
	}

	public List findByTecher(Object techer) {
		return findByProperty(TECHER, techer);
	}

	public List findByExpEnvironment(Object expEnvironment) {
		return findByProperty(EXP_ENVIRONMENT, expEnvironment);
	}

	public List findByPs(Object ps) {
		return findByProperty(PS, ps);
	}

	public List findByWeek(Object week) {
		return findByProperty(WEEK, week);
	}

	public List findByTerm(Object term) {
		return findByProperty(TERM, term);
	}

	public List findByYear(Object year) {
		return findByProperty(YEAR, year);
	}

	public List findByApplier(Object applier) {
		return findByProperty(APPLIER, applier);
	}

	public List findByIsApplied(Object isApplied) {
		return findByProperty(IS_APPLIED, isApplied);
	}

	public List findByDate(Object date) {
		return findByProperty(DATE, date);
	}

	public List findByWeight(Object weight) {
		return findByProperty(WEIGHT, weight);
	}

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

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

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

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

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

⌨️ 快捷键说明

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