📄 sclassdao.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.SClass;
import cn.hope.front.pojo.base.BaseSClassDAO;
public class SClassDAO extends BaseSClassDAO {
Logger log = Logger.getLogger(SClassDAO.class.getName());
public SClassDAO () {}
public List searchAll() throws HibernateException {
List list = null;
String sqlStr = "select sClass from SClass sClass where sClass.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 List searchByStats() throws HibernateException {
List list = null;
String sqlStr = "select sClass from SClass sClass where sClass.flag='0' and sClass.stats='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 SClass searchByKey(Integer id) throws HibernateException {
SClass sClass = null;
String sqlStr = "select sClass from SClass sClass where sClass.flag='0' and sClass.SClassid='"
+ id + "'";
try {
initialize();
List list = this.getSession().find(sqlStr);
if (list.size() > 0) {
sClass = (SClass) list.get(0);
}
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
return sClass;
}
// --------------zhang hong tao ------------------
public List U01D3() throws HibernateException {
List list = null;
//Student student=null;
String sqlStr = "from SClass c where c.flag='0' ";
try {
initialize();
list = this.getSession().find(sqlStr);
//查寻班级
System.out.println(list);
return list;
}
catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
public static void main(String[] args) {
SClassDAO sClassDAO=new SClassDAO();
try {
sClassDAO.searchAround();
} catch (HibernateException e) {
e.printStackTrace();
}
}
public List searchAround()throws HibernateException{
String sqlStr = "select sClass from SClass sClass where sClass.flag='0'";
List list = null;
try {
initialize();
list = this.getSession().find(sqlStr);
System.out.println("$$$$$$$$$$$$$$$");
}
catch(HibernateException e){
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
}
finally{
closeCurrentThreadSessions();
}
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -