应用中的hibernate错误汇总

应用中的hibernate错误汇总

1、org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed.

问题:hibernate3默认的lazy为true,使用代理模式proxy属性允许延迟加载类的持久化实例。调用session.load()方法,Hibernate开始会返回CGLIB代理,除主键外的其他值均为null。当代理的某个方法被实际调用的时候, 真实的持久化对象才会被装载,但必须在同一个session中。如session.close()前一直未调用方法,close()后再调用,报上述错误。

解决:a.hbm.xml中 class项,加上lazy=false

            b.使用session.get()方法,将不延迟,直接取出对象实例。

2、java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Can't start a cloned connection while in manual transaction mode.

问题:MS SQLServer在设置为autoCommit=false,SelectMethod=direct(SelectMethod如果不设置,默认为direct)时,处理多个statement将报以上错误

解决:在url加上设置SelectMethod=Cursor

3、java.lang.NullPointerException: Problem with checked-in Statement, discarding.

问题:oracle9i前的jdbc Driver有bug,多个statement亦会出错

解决:在http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html上下载最新的ojdbc14.jar,版本为10.2.0.1.0

你可能感兴趣的:(应用中的hibernate错误汇总)