📄 tinfodao.java
字号:
package cn.hope.front.pojo.dao;
import java.util.List;
import net.sf.hibernate.HibernateException;
import org.apache.log4j.Logger;
import cn.hope.front.pojo.TInfo;
import cn.hope.front.pojo.base.BaseTInfoDAO;
public class TInfoDAO extends BaseTInfoDAO {
Logger log = Logger.getLogger(TInfoDAO.class.getName());
/**
* Default constructor. Can be used in place of getInstance()
*/
public TInfoDAO () {}
/****************wuyongbo************/
public TInfo searchByKey(String t_id) throws HibernateException {
List list = null;
TInfo tInfo = new TInfo();
String sqlStr = "select tInfo from TInfo tInfo where tInfo.flag='0' and tInfo.TId='"+t_id+"'";
try {
initialize();
list = this.getSession().find(sqlStr);
if (list.size() > 0) {
tInfo = (TInfo) list.get(0);
}
}
catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
}
finally {
closeCurrentThreadSessions();
}
return tInfo;
}
public void modify(TInfo tInfo) throws HibernateException {
try {
initialize();
this.update(tInfo);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/****************jinxiaolei************/
public List searchAll() throws HibernateException {
List list = null;
String sqlStr = "select tInfo from TInfo tInfo where tInfo.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;
}
//==============zhang hong tao =============================
public TInfo U01DT(String name,String psw) throws HibernateException {
List list = null;
TInfo tinfo=null;
String sqlStr = "from TInfo t where t.flag='0' and t.TId='"+name+"' and t.TPassword='"+psw+"'";
try {
initialize();
//查寻名字
list = this.getSession().find(sqlStr);//从数据库提取名字和密码
System.out.println(list);
if(list!=null){
System.out.println("tttttttttttttttttttttttttt");
if(list.size()>0){ //放到实体中去
tinfo =(TInfo) list.get(0);
}else{
tinfo=null;
}
}
System.out.println(list);
return tinfo;
}
catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -