ssh运行时异常总结

1.IllegalArgumentException occurred while calling setter of cn.jwxc.oee.pojo.xxxx.matDatas

可能是hbm.xml中配置是Set集合而实体类中用的是List集合

2.org.hibernate.exception.ConstraintViolationException:违反唯一约束条件

这个也是配置的问题,xml配置的一对一,结果程序赋值的时候重复赋值了。解决办法:实体关系分析错误,可能是多对一关系。

3.java.lang.IllegalStateException: No value for key [org.hibernate.impl.SessionFactoryImpl@1b912ed] bound to thread 

以及net.sf.hibernate.HibernateException: Session is closed

这中异常应该是配置了事务的一些方法中,使用了session,close方法关闭了session,导致调用其他有关配置了事务的方法无法应用配置的事务管理。故使用getCurrentSession来创建session,这样的话,在commit后,session就自动被关闭, 也就是不用再session.close()了。openSession方法创建的session的话, 必须显示的关闭session,也就是调用session.close()方法。这样会引起上述异常。

猜你喜欢

转载自yzl495.iteye.com/blog/2389566