logidiodao.java
来自「spring+hibernate+struts开发的校务oa系统」· Java 代码 · 共 149 行
JAVA
149 行
package com.yondor.oa.db.logidio.dao;
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 Logidio.
* @see com.yondor.oa.db.Logidio
* @author MyEclipse - Hibernate Tools
*/
public class LogidioDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(LogidioDAO.class);
//property constants
public static final String TITLE = "title";
public static final String CONTENTTAG = "contenttag";
public static final String WEATHER = "weather";
public static final String MOOD = "mood";
public static final String AUTHOROP = "authorop";
protected void initDao() {
//do nothing
}
public void save(Logidio transientInstance) {
log.debug("saving Logidio instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Logidio persistentInstance) {
log.debug("deleting Logidio instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Logidio findById( java.lang.Long id) {
log.debug("getting Logidio instance with id: " + id);
try {
Logidio instance = (Logidio) getHibernateTemplate()
.get(Logidio.class, id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Logidio instance) {
log.debug("finding Logidio 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 Logidio instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Logidio 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 findByTitle(Object title) {
return findByProperty(TITLE, title);
}
public List findByContenttag(Object contenttag) {
return findByProperty(CONTENTTAG, contenttag);
}
public List findByWeather(Object weather) {
return findByProperty(WEATHER, weather);
}
public List findByMood(Object mood) {
return findByProperty(MOOD, mood);
}
public List findByAuthorop(Object authorop) {
return findByProperty(AUTHOROP, authorop);
}
public Logidio merge(Logidio detachedInstance) {
log.debug("merging Logidio instance");
try {
Logidio result = (Logidio) getHibernateTemplate()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Logidio instance) {
log.debug("attaching dirty Logidio instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Logidio instance) {
log.debug("attaching clean Logidio instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static LogidioDAO getFromApplicationContext(ApplicationContext ctx) {
return (LogidioDAO) ctx.getBean("LogidioDAO");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?