是你的事务处理的有问题!修改你的事务处理!public UserInfo authenticate() throws Exception {
Transaction t = null;
try {
Session session = HibernateUtil.currentSession();
t = session.beginTransaction();
Query q = session.createQuery("select u from u in class UserInfo where u.email=:email and u.password=:password");
q.setParameter("email", getEmail());
q.setParameter("password", getPassword());
List result = q.list();
if (!result.isEmpty()) {
return (UserInfo)result.iterator().next();
}
else {
ValidationDelegate delegate = (ValidationDelegate) getBeans().getBean("delegate");
delegate.setFormComponent(null);
delegate.record("Login failed, wrong username or password", null);
}
t.commit();
} catch (HibernateException e) {
t.rollback();
e.printStackTrace();
} finally {
if (HibernateUtil.currentSession() != null)
try {
HibernateUtil.currentSession().flush();
HibernateUtil.closeSession();
} catch (Exception e) {
e.printStackTrace();
}
} return null;
}
Transaction t = null;
try {
Session session = HibernateUtil.currentSession();
t = session.beginTransaction();
Query q = session.createQuery("select u from u in class UserInfo where u.email=:email and u.password=:password");
q.setParameter("email", getEmail());
q.setParameter("password", getPassword());
List result = q.list();
if (!result.isEmpty()) {
return (UserInfo)result.iterator().next();
}
else {
ValidationDelegate delegate = (ValidationDelegate) getBeans().getBean("delegate");
delegate.setFormComponent(null);
delegate.record("Login failed, wrong username or password", null);
}
t.commit();
} catch (HibernateException e) {
t.rollback();
e.printStackTrace();
} finally {
if (HibernateUtil.currentSession() != null)
try {
HibernateUtil.currentSession().flush();
HibernateUtil.closeSession();
} catch (Exception e) {
e.printStackTrace();
}
} return null;
}
解决方案 »
- servlet中的session如何与action中的session同步
- jdbc里面增删改查 里面除了用ID查询 还有个是FindAll 查询啥意思 里面用到了递归的方法
- java在编译器,到底做了那些工作?
- 请问在ssh框架中实现删除时怎么知道是否与其他表有引用关系
- SQL翻译成HQL 问题
- 求解:JSF+Spring+Hibernate集成开发抛出的异常
- 关于hibernate的连接池问题,急!!
- struts中的.do是什么东西
- 持久性框架的选择---你了解持久性框架么?进来看看
- Help me please......关于pop3协议>>>(要再加分可面谈)
- 请问tomcat支持分布式事务处理功能吗
- eclipse3.1+struts+hibernate+tomcat进行Web开发(分虽不高,但是还是希望大家进来看看。)
超过8小时没任何操作的连接被服务器端强制断开连接,
而此时连接池中认为该连接还是有效的。解决办法参考下面这篇blog:http://bjzhanghao.cnblogs.com/archive/2004/12/10/75145.html