84669 人が学習中
152542 人が学習中
20005 人が学習中
5487 人が学習中
7821 人が学習中
359900 人が学習中
3350 人が学習中
180660 人が学習中
48569 人が学習中
18603 人が学習中
40936 人が学習中
1549 人が学習中
1183 人が学習中
32909 人が学習中
サーブレットの休止状態により、同時実行性が高い条件下では一部のスレッドで org.hibernate.SessionException: Session is Closed! が発生しますが、シングルスレッド条件では発生しません。
BaseDAO.java
连接池配少了吧
解决了,将代码改成如下即可
public UserEntity queryByMainKey(long phone) { int retry = 0; entity = new UserEntity(); Session session = factory.getCurrentSession(); Transaction transaction = session.beginTransaction(); while (retry++ < 3) { try { //if(!session.isOpen()) session.beginTransaction(); Query q = session.createQuery("from UserEntity where phone=?"); q.setLong(0, phone); if (q.list() == null || q.list().size() == 0) { return null; } entity.Clone((UserEntity) q.list().get(0)); return entity; } catch (Exception e) { e.printStackTrace(); continue; } } return null; }
连接池配少了吧
解决了,将代码改成如下即可