📄 docleavedao.java
字号:
package com.oa.document.db;
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;
/**
* Data access object (DAO) for domain model class Docleave.
* @see com.oa.document.db.Docleave
* @author MyEclipse - Hibernate Tools
*/
public class DocleaveDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(DocleaveDAO.class);
//property constants
public static final String SENDER = "sender";
public static final String DEPTID = "deptid";
public static final String POSTID = "postid";
public static final String LEAVETYPE = "leavetype";
public static final String LEAVEPLACE = "leaveplace";
public static final String TEL = "tel";
public static final String STARTTIME = "starttime";
public static final String ENDTIME = "endtime";
public static final String TOTALDAY = "totalday";
public static final String TOTALHOUR = "totalhour";
protected void initDao() {
//do nothing
}
public boolean save(Docleave transientInstance) {
log.debug("saving Docleave instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
return true;
} catch (RuntimeException re) {
log.error("save failed", re);
re.printStackTrace();
return false;
}
}
public void updateDocstate(Integer id, String state) {
log.debug("updateing Docleave instance");
try {
Docleave vo = (Docleave)getHibernateTemplate().get(Docleave.class, id);
vo.setState(state);
getHibernateTemplate().saveOrUpdate(vo);
log.debug("update successful");
} catch (RuntimeException re) {
log.error("update failed", re);
throw re;
}
}
public boolean updateDoc(Integer id, Docleave instance) {
log.debug("updateing Docleave instance");
try {
Docleave vo = (Docleave)getHibernateTemplate().get(Docleave.class, id);
vo.setLeavetype(instance.getLeavetype());
vo.setLeaveplace(instance.getLeaveplace());
vo.setTel(instance.getTel());
vo.setStarttime(instance.getStarttime());
vo.setEndtime(instance.getEndtime());
vo.setTotalday(instance.getTotalday());
vo.setTotalhour(instance.getTotalhour());
vo.setState(instance.getState());
getHibernateTemplate().saveOrUpdate(vo);
log.debug("update successful");
return true;
} catch (RuntimeException re) {
log.error("update failed", re);
re.printStackTrace();
return false;
}
}
public void delete(Docleave persistentInstance) {
log.debug("deleting Docleave instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Docleave findById( java.lang.Integer id) {
log.debug("getting Docleave instance with id: " + id);
try {
Docleave instance = (Docleave) getHibernateTemplate()
.get("com.oa.document.db.Docleave", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Docleave instance) {
log.debug("finding Docleave 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 Docleave instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Docleave 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 findBySender(Object sender) {
return findByProperty(SENDER, sender);
}
public List findByDeptid(Object deptid) {
return findByProperty(DEPTID, deptid);
}
public List findByPostid(Object postid) {
return findByProperty(POSTID, postid);
}
public List findByLeavetype(Object leavetype) {
return findByProperty(LEAVETYPE, leavetype);
}
public List findByLeaveplace(Object leaveplace) {
return findByProperty(LEAVEPLACE, leaveplace);
}
public List findByTel(Object tel) {
return findByProperty(TEL, tel);
}
public List findByStarttime(Object starttime) {
return findByProperty(STARTTIME, starttime);
}
public List findByEndtime(Object endtime) {
return findByProperty(ENDTIME, endtime);
}
public List findByTotalday(Object totalday) {
return findByProperty(TOTALDAY, totalday);
}
public List findByTotalhour(Object totalhour) {
return findByProperty(TOTALHOUR, totalhour);
}
public Docleave merge(Docleave detachedInstance) {
log.debug("merging Docleave instance");
try {
Docleave result = (Docleave) getHibernateTemplate()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Docleave instance) {
log.debug("attaching dirty Docleave instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Docleave instance) {
log.debug("attaching clean Docleave instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static DocleaveDAO getFromApplicationContext(ApplicationContext ctx) {
return (DocleaveDAO) ctx.getBean("DocleaveDAO");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -