控制台没有输出错误信息,但是junit就是棕色的,运行不成功
package hlx.DaoImpl;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import po.HibernateSessionFactory;
import hlx.Dao.UsersDao;
import hlx.bean.Userinfo;
public class UsersDaoImpl implements UsersDao{
public boolean userLogin(Userinfo u) {
// TODO Auto-generated method stub
Transaction tr = null;
String hql ="";
try {
Session session = HibernateSessionFactory.getSession();
hql="from Userinfo where userName=? and userPassword =?";
tr = session.beginTransaction();
Query query = session.createQuery(hql);
query.setParameter(0, u.getUserName());
query.setParameter(1, u.getUserPassword());
List list = query.list();
tr.commit();
session.close();
if(list.size()>0){
return true;
}else{
return false;
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
return false;
}finally{
if(tr!=null){
tr=null; //释放资源
}
}
}
}