Im running into a strange issue with an insert. The insert actually is successfull and the CreatedOn row is complete, but it appears when a hibernate flush is executed, i get the below stack trace. Anybody seen this before?
Hibernate version:
3.10
Mapping documents:
<hibernate-mapping>
<class
name="com.peopleclick.inventorymanagement.softwaredistribution.business.SoftwareDistribution"
table="SoftwareDistribution"
schema="dbo"
mutable="true" >
<id name="code" type="string" unsaved-value="null" >
<column name="SoftwareDistCD" />
</id>
<property name="name" type="string" column="Name" not-null="true" />
<property name="description" type="string" column="Description" not-null="true" />
<!--
<set name="serverRoles" table="SoftwareDistributionServerRole" lazy="false">
<key column="SoftwareDistCD" />
<many-to-many column="ServerRoleCD" class="com.peopleclick.inventorymanagement.device.business.ServerRole" />
</set>
-->
<property name="rowStatus" type="com.peopleclick.appcore.rowstatus.RowStatusUserType"
column="RowStatus" not-null="true" />
<property name="createdOn" generated="insert" type="com.peopleclick.framework.hibernate.TimestampType">
<column name="CreatedOn" length="23"/>
</property>
<property name="modifiedOn" type="com.peopleclick.framework.hibernate.TimestampType">
<column name="ModifiedOn" length="23"/>
</property>
</class>
Code between sessionFactory.openSession() and session.close():
public void create(SoftwareDistribution pObj)
{
if ( pObj.getRowStatus() == null )
{
pObj.setRowStatus( RowStatus.ACTIVE );
}
if ( pObj.getModifiedOn() == null )
{
pObj.setModifiedOn( new Date() );
}
getHibernateTemplate().save( pObj );
}
Full stack trace of any exception that occurs:
14:06:41 WARN org.hibernate.util.JDBCExceptionReporter 77 SQL Error: 515, SQLState: 23000
14:06:41 ERROR org.hibernate.util.JDBCExceptionReporter 78 Cannot insert the value NULL into column 'CreatedOn', table 'EngineeringInventory_100_Dev01.dbo.SoftwareDistribution'; column does not allow nulls. UPDATE fails.
14:06:41 ERROR org.hibernate.event.def.AbstractFlushingEventListener 301 Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not update: [com.peopleclick.inventorymanagement.softwaredistribution.business.SoftwareDistribution#TST]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2375)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2257)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2557)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:388)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:363)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:622)
at com.peopleclick.inventorymanagement.softwaredistribution.dao.SoftwareDistributionDAOImpl.create(SoftwareDistributionDAOImpl.java:46)
at com.peopleclick.inventorymanagement.softwaredistribution.service.SoftwareDistributionServiceImpl.createSoftwareDistribution(SoftwareDistributionServiceImpl.java:33)
at com.peopleclick.inventorymanagement.device.ui.webapp.DeviceController.showSoftwareDistribution(DeviceController.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:434)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:372)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:755)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:350)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
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.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'CreatedOn', table 'EngineeringInventory_100_Dev01.dbo.SoftwareDistribution'; column does not allow nulls. UPDATE fails.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getPrepExecResponse(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PreparedStatementExecutionRequest.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.CancelableRequest.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2353)
... 43 more
Name and version of the database you are using:
SQL 2003
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html