📄 tfiledao.java
字号:
package dao;
import java.util.List;
import model.TFile;
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;
/**
* Hibernate反向工程自动生成的对数据库进行增,删,改,查的类
* A data access object (DAO) providing persistence and search support for TFile
* entities. Transaction control of the save(), update() and delete() operations
* can directly support Spring container-managed transactions or they can be
* augmented to handle user-managed Spring transactions. Each of these methods
* provides additional information for how to configure it for the desired type
* of transaction control.
*
* @see model.TFile
* @author MyEclipse Persistence Tools
*/
public class TFileDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(TFileDAO.class);
// property constants
public static final String FILE_NAME = "fileName";
public static final String FILE_CONTENT = "fileContent";
public static final String REMARK = "remark";
protected void initDao() {
// do nothing
}
public void save(TFile transientInstance) {
log.debug("saving TFile instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(TFile persistentInstance) {
log.debug("deleting TFile instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public TFile findById(java.lang.String id) {
log.debug("getting TFile instance with id: " + id);
try {
TFile instance = (TFile) getHibernateTemplate()
.get("model.TFile", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(TFile instance) {
log.debug("finding TFile 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 TFile instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from TFile 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 findByFileName(Object fileName) {
return findByProperty(FILE_NAME, fileName);
}
public List findByFileContent(Object fileContent) {
return findByProperty(FILE_CONTENT, fileContent);
}
public List findByRemark(Object remark) {
return findByProperty(REMARK, remark);
}
public List findAll() {
log.debug("finding all TFile instances");
try {
String queryString = "from TFile";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public TFile merge(TFile detachedInstance) {
log.debug("merging TFile instance");
try {
TFile result = (TFile) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(TFile instance) {
log.debug("attaching dirty TFile instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(TFile instance) {
log.debug("attaching clean TFile instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static TFileDAO getFromApplicationContext(ApplicationContext ctx) {
return (TFileDAO) ctx.getBean("TFileDAO");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -