📄 tclasshwdao.java
字号:
package cn.hope.front.pojo.dao;
import java.util.List;
import org.apache.log4j.Logger;
import net.sf.hibernate.HibernateException;
import cn.hope.front.pojo.TClassHw;
import cn.hope.front.pojo.base.BaseTClassHwDAO;
public class TClassHwDAO extends BaseTClassHwDAO {
Logger log = Logger.getLogger(TClassHwDAO.class.getName());
/**
* Default constructor. Can be used in place of getInstance()
*/
public TClassHwDAO () {}
/**************jinxl**************/
/**
* 插入数据方法
*
* @param tFile
* @return
* @throws HibernateException
*/
public Integer insert(TClassHw tClassHw) throws HibernateException {
try {
initialize();// 初始化session
return (Integer) this.save(tClassHw);// 调用生成好的父类方法save(),返回被插入数据的主键
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();// 关闭当前session
}
}
public void modify(TClassHw tClassHw) throws HibernateException {
try {
initialize();
this.update(tClassHw);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
public List searchAll() throws HibernateException {
List list = null;
String sqlStr = "select tClassHw from TClassHw tClassHw where tClassHw.flag='0' ";
try {
initialize();
list = this.getSession().find(sqlStr);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
return list;
}
public TClassHw searchByKey(Integer id) throws HibernateException {
TClassHw tClassHw = null;
String sqlStr = "select tClassHw from TClassHw tClassHw where tClassHw.flag='0' and tClassHw.id='"
+ id + "'";
try {
initialize();
List list = this.getSession().find(sqlStr);
if (list.size() > 0) {
tClassHw = (TClassHw) list.get(0);
}
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
return tClassHw;
}
/*****************jinxl*******************/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -