📄 doctaskdao.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 Doctask.
* @see com.oa.document.db.Doctask
* @author MyEclipse - Hibernate Tools
*/
public class DoctaskDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(DoctaskDAO.class);
//property constants
public static final String SENDER = "sender";
public static final String TASKID = "taskid";
public static final String TASKNAME = "taskname";
public static final String TASKAIM = "taskaim";
public static final String ARRANGE = "arrange";
public static final String FILE = "file";
public static final String TRUEFILE = "truefile";
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(Doctask transientInstance) {
log.debug("saving Doctask instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
return true;
} catch (RuntimeException re) {
log.error("save failed", re);
re.printStackTrace();
return false;
}
}
public Doctask findMaxDocid() {
log.debug("getting MaxDocid ");
try {
List list = getHibernateTemplate()
.find("from Doctask order by id desc limit 1");
Doctask instance = null;
if(list != null && list.size() > 0){
instance = (Doctask)list.get(0);
}
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public void updateDocstate(Integer id, String state) {
log.debug("updateing Doctask instance");
try {
Doctask vo = (Doctask)getHibernateTemplate().get(Doctask.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, Doctask instance) {
log.debug("updateing Doctask instance");
try {
Doctask vo = (Doctask)getHibernateTemplate().get(Doctask.class, id);
vo.setTaskname(instance.getTaskname());
vo.setArrange(instance.getArrange());
vo.setTaskaim(instance.getTaskaim());
vo.setStarttime(instance.getStarttime());
vo.setEndtime(instance.getEndtime());
vo.setFile(instance.getFile());
vo.setTruefile(instance.getTruefile());
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(Doctask persistentInstance) {
log.debug("deleting Doctask instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Doctask findById( java.lang.Integer id) {
log.debug("getting Doctask instance with id: " + id);
try {
Doctask instance = (Doctask) getHibernateTemplate()
.get("com.oa.document.db.Doctask", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Doctask instance) {
log.debug("finding Doctask 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 Doctask instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Doctask 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 findByTaskid(Object taskid) {
return findByProperty(TASKID, taskid);
}
public List findByTaskname(Object taskname) {
return findByProperty(TASKNAME, taskname);
}
public List findByTaskaim(Object taskaim) {
return findByProperty(TASKAIM, taskaim);
}
public List findByArrange(Object arrange) {
return findByProperty(ARRANGE, arrange);
}
public List findByFile(Object file) {
return findByProperty(FILE, file);
}
public List findByTruefile(Object truefile) {
return findByProperty(TRUEFILE, truefile);
}
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 Doctask merge(Doctask detachedInstance) {
log.debug("merging Doctask instance");
try {
Doctask result = (Doctask) getHibernateTemplate()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Doctask instance) {
log.debug("attaching dirty Doctask instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Doctask instance) {
log.debug("attaching clean Doctask instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static DoctaskDAO getFromApplicationContext(ApplicationContext ctx) {
return (DoctaskDAO) ctx.getBean("DoctaskDAO");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -