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

📄 docmovedao.java

📁 一个oa系统
💻 JAVA
字号:
package com.oa.document.db;

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;

/**
 * Data access object (DAO) for domain model class Docmove.
 * 
 * @see com.oa.document.db.Docmove
 * @author MyEclipse - Hibernate Tools
 */
public class DocmoveDAO extends HibernateDaoSupport {

	private static final Log log = LogFactory.getLog(DocmoveDAO.class);

	// property constants
	public static final String DOCTYPE = "doctype";

	public static final String DOCID = "docid";

	public static final String AUDITOR = "auditor";

	public static final String OPINION = "opinion";

	public static final String NEXTAUDITOR = "nextauditor";

	protected void initDao() {
		// do nothing
	}

	public boolean save(Docmove transientInstance) {
		log.debug("saving Docmove instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
			return true;
		} catch (RuntimeException re) {
			log.error("save failed", re);
			re.printStackTrace();
			return false;
		}
	}

	public List findWaitDocByNextAuditor(String nextauditor) {
		log.debug("finding Docmove instance with nextauditor: " + nextauditor);
		try {
			String queryString = "from Docmove as model where model.nextauditor like ? and model.yiauditor = ?";
			return getHibernateTemplate().find(
					queryString,
					new String[]{"%," + nextauditor + ",%", " "});
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	
	public List findYiDealDocByYiAuditor(String yiauditor) {
		log.debug("finding Docmove instance with yiauditor: " + yiauditor);
		try {
			String queryString = "from Docmove as model where model.yiauditor = ? and model.yiauditor <> model.auditor";
			return getHibernateTemplate().find(queryString, yiauditor);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	
	public List findAllDoc(){
		log.debug("finding Docmove instance with yiauditor: ");
		try {
			String queryString = "from Docmove group by docid";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	
	public void updateYiAuditorById(java.lang.Integer id, String yiauditor) {
		log.debug("updateing Docmove instance with id: " + id);
		try {
			Docmove vo = (Docmove)getHibernateTemplate().get(Docmove.class, id);
			if(vo != null){
				vo.setYiauditor(yiauditor);
				getHibernateTemplate().saveOrUpdate(vo);
			}
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public Docmove findLastDocByDocid(String type, String docid) {
		log.debug("updateing Docmove instance with docid: " + docid);
		try {
			Docmove vo = null;
			String queryString = "from Docmove where doctype=? and docid=? order by id desc limit 1";
			List list = getHibernateTemplate().find(queryString, new String[]{type, docid});
			if(list!=null && list.size()>0){
				vo = (Docmove)list.get(0); 
			}
			return vo; 
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public List findAuditor(String type, String docid) {//获取审核意见
		log.debug("updateing Docmove instance with docid: " + docid);
		try {
			String queryString = "from Docmove where doctype=? and docid=?";
			List list = getHibernateTemplate().find(queryString, new String[]{type, docid});
			return list; 
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

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

	public Docmove findById(java.lang.Integer id) {
		log.debug("getting Docmove instance with id: " + id);
		try {
			Docmove instance = (Docmove) getHibernateTemplate().get(
					"com.oa.document.db.Docmove", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

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

	public List findByDocid(Object docid) {
		return findByProperty(DOCID, docid);
	}

	public List findByAuditor(Object auditor) {
		return findByProperty(AUDITOR, auditor);
	}

	public List findByOpinion(Object opinion) {
		return findByProperty(OPINION, opinion);
	}

	public List findByNextauditor(Object nextauditor) {
		return findByProperty(NEXTAUDITOR, nextauditor);
	}

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

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

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

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

⌨️ 快捷键说明

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