-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: ConstraintViolationException in join table
PostPosted: Fri Oct 23, 2009 6:35 pm 
Newbie

Joined: Fri Oct 23, 2009 6:33 pm
Posts: 1
I'm running into a ConstraintViolationException when I try to save an object with a @OneToMany map in it. Hibernate either seems to think that I'm trying to put a NULL into the mapped list or it may be putting it there itself. The problem seems to happen sporadically: with some databases it's easily reproducible, but with others I can't get it to happen at all.

I'm kind of a newbie at both Hibernate and Hibernate Annotations, so any help at all would be much appreciated.

I have two classes: Camera and AlarmZone (which extends a 3rd class, Zone). Among other things, Camera contains a list of IDs of AlarmZone objects. Here's the class declarations:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "cameras")
public class Camera
{
private Serializable id;

private List<Serializable> alarm_zones = new ArrayList<Serializable>();

...

@Id(generate = GeneratorType.SEQUENCE)
@Type(type = "java.lang.Long")
public java.io.Serializable getId()
{
return this.id;
}

public void setId(java.io.Serializable id)
{
this.id = id;
}

@OneToMany(targetEntity = java.lang.Long.class, fetch = FetchType.EAGER)
@JoinTable(table = @Table(name = "cameraalarmzones"))
public List<Serializable> getAlarmZones()
{
return alarm_zones;
}

public void setAlarmZones(List<Serializable> alarm_zones)
{
this.alarm_zones = alarm_zones;
}

...
}

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "zones")
public class Zone
{
private Serializable id;

...

@Id(generate = GeneratorType.SEQUENCE)
@Type(type = "java.lang.Long")
public java.io.Serializable getId()
{
return this.id;
}

public void setId(java.io.Serializable id)
{
this.id = id;
}
}

@Entity
@Table(name = "alarmzones")
public class AlarmZone extends Zone
{
...
}

Whenever I save an object, I use what I understand to be boilerplate commit code:

public Persistable makePersistent(Object entity)
{
try
{
Hibernate.getSession().beginTransaction();
Hibernate.getSession().saveOrUpdate(entity);
Hibernate.getSession().flush();
Hibernate.getSession().getTransaction().commit();
} catch (RuntimeException e)
{
Hibernate.getSession().getTransaction().rollback();
logger.error("makePersistent(" + entity.getClass().getSimpleName()
+ ")", e);
}
return entity;
}

The problem happens when I save an AlarmZone, then put its ID into the Camera's list and try to save the camera. To get better debug info, I followed the advice from viewtopic.php?p=2220295 and set my batch size to be 0 and turned on DEBUG level debugging in log4j. Here's the stack trace for the error (along with the preceding few lines):

[2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractCollectionPersister.java:947) - Deleting collection: [x.y.z.Camera.alarmZones#641] [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractBatcher.java:311) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractBatcher.java:346) - delete from cameraalarmzones where cameras_id=? [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractBatcher.java:424) - preparing statement [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (NullableType.java:79) - binding '641' to parameter: 1 [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractCollectionPersister.java:977) - done deleting collection [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractCollectionPersister.java:999) - Inserting collection: [x.y.z.Camera.alarmZones#641] [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractBatcher.java:319) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractBatcher.java:470) - closing statement [2009-10-23 14:33:07,606] DEBUG [http-8443-Processor25] (AbstractBatcher.java:311) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) [2009-10-23 14:33:07,622] DEBUG [http-8443-Processor25] (AbstractBatcher.java:346) - insert into cameraalarmzones (cameras_id, elt) values (?, ?) [2009-10-23 14:33:07,622] DEBUG [http-8443-Processor25] (AbstractBatcher.java:424) - preparing statement [2009-10-23 14:33:07,622] DEBUG [http-8443-Processor25] (NullableType.java:79) - binding '641' to parameter: 1 [2009-10-23 14:33:07,622] DEBUG [http-8443-Processor25] (NullableType.java:79) - binding '649' to parameter: 2 [2009-10-23 14:33:07,622] DEBUG [http-8443-Processor25] (AbstractBatcher.java:319) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) [2009-10-23 14:33:07,622] DEBUG [http-8443-Processor25] (AbstractBatcher.java:470) - closing statement [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (JDBCExceptionReporter.java:63) - could not insert collection: [x.y.z.Camera.alarmZones#641] [insert into cameraalarmzones (cameras_id, elt) values (?, ?)] java.sql.SQLException: Attempt to insert null into a non-nullable column: column: ALARMZONES table: CAMERAALARMZONES in statement [insert into cameraalarmzones (cameras_id, elt) values (?, ?)] at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source) at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23) at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1039) at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:51) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980) at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292) at $Proxy25.flush(Unknown Source) at com.silkspeed.ssparts.server.PersistableDAOImpl.makePersistent(PersistableDAOImpl.java:82) 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:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122) at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:68) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174) at $Proxy38.makePersistent(Unknown Source) 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:597) at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:179) at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:33) at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:76) at org.springframework.remoting.support.RemoteInvocationBasedExporter.invokeAndCreateResult(RemoteInvocationBasedExporter.java:112) at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:80) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:357) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at x.y.z.server.SessionInfo.doFilter(SessionInfo.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:619) [2009-10-23 14:33:07,637] WARN [http-8443-Processor25] (JDBCExceptionReporter.java:71) - SQL Error: -10, SQLState: 23000 [2009-10-23 14:33:07,637] ERROR [http-8443-Processor25] (JDBCExceptionReporter.java:72) - Attempt to insert null into a non-nullable column: column: ALARMZONES table: CAMERAALARMZONES in statement [insert into cameraalarmzones (cameras_id, elt) values (?, ?)] [2009-10-23 14:33:07,637] ERROR [http-8443-Processor25] (AbstractFlushingEventListener.java:299) - Could not synchronize database state with session org.hibernate.exception.ConstraintViolationException: could not insert collection: [x.y.z.Camera.alarmZones#641] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1058) at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:51) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980) at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292) at $Proxy25.flush(Unknown Source) at com.silkspeed.ssparts.server.PersistableDAOImpl.makePersistent(PersistableDAOImpl.java:82) 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:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122) at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:68) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174) at $Proxy38.makePersistent(Unknown Source) 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:597) at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:179) at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:33) at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:76) at org.springframework.remoting.support.RemoteInvocationBasedExporter.invokeAndCreateResult(RemoteInvocationBasedExporter.java:112) at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:80) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:357) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at x.y.z.server.SessionInfo.doFilter(SessionInfo.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:619) Caused by: java.sql.SQLException: Attempt to insert null into a non-nullable column: column: ALARMZONES table: CAMERAALARMZONES in statement [insert into cameraalarmzones (cameras_id, elt) values (?, ?)] at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source) at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23) at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1039) ... 58 more [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (JDBCTransaction.java:152) - rollback [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (JDBCTransaction.java:193) - re-enabling autocommit [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (JDBCTransaction.java:163) - rolled back JDBC Connection [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (JDBCContext.java:207) - after transaction completion [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (ConnectionManager.java:296) - aggressively releasing JDBC connection [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (ConnectionManager.java:333) - closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)] [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (DriverManagerConnectionProvider.java:129) - returning connection to pool, pool size: 1 [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (SessionImpl.java:434) - after transaction completion [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (SessionImpl.java:368) - automatically closing session [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (SessionImpl.java:296) - closing session [2009-10-23 14:33:07,637] DEBUG [http-8443-Processor25] (ConnectionManager.java:267) - connection already null in cleanup : no action [2009-10-23 14:33:07,637] ERROR [http-8443-Processor25] (PersistableDAOImpl.java:87) - makePersistent(Camera) org.hibernate.exception.ConstraintViolationException: could not insert collection: [x.y.z.Camera.alarmZones#641] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1058) at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:51) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980) at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292) at $Proxy25.flush(Unknown Source) at com.silkspeed.ssparts.server.PersistableDAOImpl.makePersistent(PersistableDAOImpl.java:82) 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:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122) at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:68) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174) at $Proxy38.makePersistent(Unknown Source) 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:597) at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:179) at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:33) at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:76) at org.springframework.remoting.support.RemoteInvocationBasedExporter.invokeAndCreateResult(RemoteInvocationBasedExporter.java:112) at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:80) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:357) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at x.y.z.server.SessionInfo.doFilter(SessionInfo.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:619) Caused by: java.sql.SQLException: Attempt to insert null into a non-nullable column: column: ALARMZONES table: CAMERAALARMZONES in statement [insert into cameraalarmzones (cameras_id, elt) values (?, ?)] at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source) at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23) at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1039) ... 58 more

Here's my hibernate config file:

<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:file:dbfilename;shutdown=true</property>
<property name="connection.username">*************</property>
<property name="connection.password">*************</property>
<property name="connection.autocommit">true</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>

<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.jdbc.fetch_size">0</property>

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>


<mapping class="com.silkspeed.sightlogix.cs.AlarmZone"/>
<mapping class="com.silkspeed.sightlogix.cs.Camera" />
<mapping class="com.silkspeed.sightlogix.cs.Zone"/>

...

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: ConstraintViolationException in join table
PostPosted: Sat Oct 24, 2009 1:02 pm 
Newbie

Joined: Sat Oct 24, 2009 6:59 am
Posts: 3
I also got the same kind of exception. if anyone experienced this , please advice us . it would be appreciated.

24 Oct, 2009 10:20:59 PM org.slf4j.impl.JCLLoggerAdapter error
SEVERE: Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:420)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694)
at com.vendor.audit.management.system.dao.impl.UserLoginDAOImpl.createAppUser(UserLoginDAOImpl.java:70)
at com.vendor.audit.management.system.service.impl.UserLoginServiceImpl.createAppUser(UserLoginServiceImpl.java:43)
at com.vendor.audit.management.system.action.admin.UserLoginAction.createUser(UserLoginAction.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.struts2.rest.RestActionInvocation.invokeAction(RestActionInvocation.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.DefaultActionProxy.execute(DefaultActionProxy.java:129)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (SCOTT.USER_CITY_ID_FK) violated - parent key not found

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:367)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9119)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 77 more

Thanks in Advance
Sasikumar


Top
 Profile  
 
 Post subject: Re: ConstraintViolationException in join table
PostPosted: Mon Oct 26, 2009 10:29 am 
Beginner
Beginner

Joined: Mon Sep 14, 2009 9:29 am
Posts: 30
I think the problem is with the data type mentioned in .hbm file...Hibernate is not able to convert the state what u mentioned ..check that..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.