My web application is in production with hibernate 3.0.3. Trying to upgrade to 3.1.3, but having problems reading serialized blobs. The blob was read and written by my app using hibernate 3.0.3, and is not null, but hibernate 3.1.3 disagrees. SQL*Plus confirms the field has data.
Web Server:
Windows XP SP2
Tomcat 5.5.16 with DBCP 1.2.1
Apache 2.0.55
Hibernate version: 3.1.3
Mapping documents:
Code:
<hibernate-mapping>
<class name="User" table="T_USERS">
<cache usage="read-write" />
<id name="id" type="int" unsaved-value="-1">
<column name="PK_USER" sql-type="int" not-null="true" />
<generator class="select">
<param name="key">tempID</param>
</generator>
</id>
<property name="username" column="USER_ID" />
<property name="password" column="PASSWORD" />
<property name="firstName" column="FIRST_NAME" />
<property name="middleName" column="MIDDLE_NAME" />
<property name="lastName" column="LAST_NAME" />
<property name="tempID" column="TEMP_ID" />
<many-to-one
name="prefs"
class="org.etdm.model.UserPrefs">
<column name="FK_USER_PREFS" />
</many-to-one>
</class>
<class name="UserPrefs" table="T_USER_PREFS" lazy="true">
<cache usage="read-write" />
<id name="id" type="int" unsaved-value="-1">
<column name="PK_USER_PREFS" sql-type="int" not-null="true" />
<generator class="select">
<param name="key">tempID</param>
</generator>
</id>
<property name="sessionState" column="SESSION_STATE" lazy="true"/>
<property name="tempID" column="TEMP_ID" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
SessionFactory sessionFactory;
ThreadLocal hibernateSession;
// called exactly once on web app startup
public boolean startHibernate() {
try {
hibernateSession = new ThreadLocal();
Configuration configuration = new Configuration();
// add hbm files to configuration....
configuration.configure(new File(application.getRealPath("/WEB-INF/hibernate/hibernate.cfg.xml")));
sessionFactory = configuration.buildSessionFactory();
} catch (Exception ex) {
System.out.println(ex);
hibernateException = ex;
return false;
}
return true;
}
public Session newHibernateSession() throws HibernateException {
if (hibernateSession.get() != null) {
closeHibernateSession();
}
Session s = sessionFactory.openSession();
hibernateSession.set(s);
s.setCacheMode(CacheMode.NORMAL);
return s;
}
// called by JSP to get hibernate session
public Session currentHibernateSession() throws HibernateException {
Session s = (Session)hibernateSession.get();
if (s == null || !s.isOpen() || !s.isConnected()) {
closeHibernateSession();
return newHibernateSession();
}
return s;
}
// also called when HTTP session is destroyed
public void closeHibernateSession() throws HibernateException {
Session s = (Session)hibernateSession.get();
hibernateSession.set(null);
if (s != null)
s.close();
}
Full stack trace of any exception that occurs:Jul 11, 2006 5:59:46 PM org.hibernate.type.NullableType nullSafeGet
INFO: could not read column value from result set: SESSION2_122_0_; null
Jul 11, 2006 5:59:46 PM org.hibernate.jdbc.AbstractBatcher closeQueryStatement
WARNING: exception clearing maxRows/queryTimeout
java.sql.SQLException: org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement is closed.
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.checkOpen(DelegatingStatement.java:136)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.getMaxRows(DelegatingStatement.java:234)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:225)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:162)
at org.hibernate.loader.Loader.doQuery(Loader.java:714)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:749)
at org.more.do.SessionFilter.doFilter(SessionFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:365)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Jul 11, 2006 5:59:46 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at oracle.jdbc.driver.OracleStatement.wasNullValue(OracleStatement.java:3016)
at oracle.jdbc.driver.OracleResultSetImpl.wasNull(OracleResultSetImpl.java:111)
at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.wasNull(DelegatingResultSet.java:171)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:114)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1899)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1300)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:749)
at org.more.do.SessionFilter.doFilter(SessionFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:365)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Name and version of the database you are using:Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
JDBC driver: Oracle JDBC driver, version: 10.1.0.2.0
The generated SQL (show_sql=true):Hibernate: select user0_.PK_USER as PK1_120_, user0_.USER_ID as USER2_120_, user0_.PASSWORD as PASSWORD120_, user0_.FIRST_NAME as FIRST4_120_, user0_.MIDDLE_NAME as MIDDLE5_120_, user0_.LAST_NAME as LAST6_120_, user0_.TEMP_ID as TEMP7_120_, user0_.FK_USER_PREFS as FK8_120_ from T_USERS user0_ where user0_.USER_ID=?
Hibernate: select userprefs0_.PK_USER_PREFS as PK1_122_0_, userprefs0_.SESSION_STATE as SESSION2_122_0_, userprefs0_.TEMP_ID as TEMP3_122_0_ from T_USER_PREFS userprefs0_ where userprefs0_.PK_USER_PREFS=?
SessionFilter does the following to generate the above SQL:
Code:
// userID is set elsewhere. it's not null.
Integer userID = (Integer)session.getAttribute("userID");
Query q = appManager.currentHibernateSession().createQuery("from User where id = ?");
q.setInteger(0,userID.intValue());
currentUser = (User)q.uniqueResult();
Both the user record and user_prefs record exist and are not null. All I've changed is hibernate3.jar file.
Can anyone help?