📄 tfiledaoimpl.java
字号:
package com.dao;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.model.TFile;
import com.sun.org.apache.commons.logging.Log;
import com.sun.org.apache.commons.logging.LogFactory;
public class TFileDAOImpl extends HibernateDaoSupport implements TFileDAO{
private static final Log log = LogFactory.getLog(TFileDAOImpl.class);
// property constants
public TFile getById(int id) {
return (TFile)getHibernateTemplate().get(TFile.class, id);
}
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 deleteById(int id) {
log.debug("deleting TFile instance");
try {
getHibernateTemplate().delete(getById(id));
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public TFile findById(int id) {
log.debug("getting TFile instance with id: " + id);
try {
TFile instance = (TFile) getHibernateTemplate().get(TFile.class,id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List<TFile> 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;
}
}
/**
* 取记录总数
* @return int
*/
public int getFilesCount() {
log.debug("getting file count:");
int count = 0;
//注意:此TFile为对象不是表。
String queryString = "select count(*) from TFile";
try {
count = ((Integer) getHibernateTemplate().iterate(queryString).next()).intValue();
return count;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -