I'm running into the problem described here,
http://forum.springframework.org/showthread.php?t=9702. And indeed, their session.clear() suggestion does work around the issue.
Why is this occuring though? Logging indicates this is the first time the session is opened (I use the HibernateService defined in the Hibernate in Action book). Nothing could have "dirtied" the objects at this point. Why is my query causing it to execute an UPDATE? And why is the update failing?
Hibernate version:
2.1
Mapping documents:
<class name="DashboardSummary" table="DASH_BOARD_SUMMARY">
<id name="id" column="ID">
<generator class="assigned" />
</id>
<set name="serviceGroupSummary" lazy="true" inverse="true" >
<key column="SUMMARY_ID"/>
<one-to-many class="ServiceGroupSummary"/>
</set>
</class>
<class name="ServiceGroupSummary" table="SERVICE_GROUP_DASH_BOARD" >
<id name="id" column="ID">
<generator class="assigned" />
</id>
<many-to-one name="dashboardSummary" class="DashboardSummary" column="SUMMARY_ID" />
</class>
Code between sessionFactory.openSession() and session.close():
try {
LOG.info("getServiceGroupSummary enter");
_hibSvc.beginTransaction();
ServiceGroupActivityQuery query = new ServiceGroupActivityQuery(criteria, _hibSvc);
result = query.createQuery().list();
_hibSvc.commitTransaction();
return result;
} catch (HibernateException e) {
throw new NableServiceException( e );
} finally {
_hibSvc.endSession();
}
}
Full stack trace of any exception that occurs:
2006-09-26 10:34:10,407 [loadSDVDashboardBackgroundThread] ERROR JDBCExceptionReporter Could not execute JDBC batch update
java.sql.BatchUpdateException: ORA-01407: cannot update ("MC"."SERVICE_GROUP_DASH_BOARD"."SUMMARY_ID") to NULL
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:126)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2421)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2372)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.ncube.nable.platform.hibernate.HibernateService.commitTransaction(HibernateService.java:246)
at com.ncube.nable.app.mc.sdv.activity.ServiceGroupActivityService.getServiceGroupSummary(ServiceGroupActivityService.java:115)
at com.ncube.nable.app.mc.sdv.gui.action.DashboardAction.loadServiceGroups(DashboardAction.java:182)
at com.ncube.nable.app.mc.sdv.gui.action.DashboardAction.execute(DashboardAction.java:93)
at com.opensymphony.webwork.interceptor.ExecuteAndWaitInterceptor$1.run(ExecuteAndWaitInterceptor.java:101)
at java.lang.Thread.run(Thread.java:595)
Name and version of the database you are using:
Oracle 9 and 10
The generated SQL (show_sql=true):
2006-09-26 10:34:09,557 [loadSDVDashboardBackgroundThread] INFO hibernate Starting new database transaction in this thread.
2006-09-26 10:34:09,557 [loadSDVDashboardBackgroundThread] DEBUG hibernate Opening new Session for this thread.
2006-09-26 10:34:10,094 [loadSDVDashboardBackgroundThread] DEBUG SQL select servicegro0_.ID as ID, servicegro0_.SERVICE_GROUP as SERVICE_2_, servicegro0_.USED_BANDWIDTH as USED_BAN3_, servicegro0_.TOTAL_BANDWIDTH as TOTAL_BA4_, servicegro0_.ACTIVE_CHANNELS as ACTIVE_C5_, servicegro0_.TOTAL_CHANNELS as TOTAL_CH6_, servicegro0_.ACTIVE_SESSIONS as ACTIVE_S7_, servicegro0_.SUMMARY_ID as SUMMARY_ID from MC.SERVICE_GROUP_DASH_BOARD servicegro0_
2006-09-26 10:34:10,360 [loadSDVDashboardBackgroundThread] DEBUG SQL select dashboards0_.ID as ID0_, dashboards0_.CREATED_AT as CREATED_AT0_, dashboards0_.VMID as VMID0_ from MC.DASH_BOARD_SUMMARY dashboards0_ where dashboards0_.ID=?
2006-09-26 10:34:10,375 [loadSDVDashboardBackgroundThread] DEBUG SQL update MC.SERVICE_GROUP_DASH_BOARD set SERVICE_GROUP=?, USED_BANDWIDTH=?, TOTAL_BANDWIDTH=?, ACTIVE_CHANNELS=?, TOTAL_CHANNELS=?, ACTIVE_SESSIONS=?, SUMMARY_ID=? where ID=?