Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

  1. ,

    Check whether privilege has the "not null" restriction. If so it always has to have a value and can never be null.

    A different reason could be a wrong implementation of a foreign key. Check whether you always correctly insert/update in both tables.

  2. ,

    Nothing is wrong with the database. When it gives you those errors, it's telling you that you are trying to input "nothing" (null) into a column that doesn't allow it. Fix it by removing the not null constraint or by passing a value to that field.

Solutions on the web

via JIRA by Ramin Haeri Azad, 1 year ago
org.hibernate.exception.ConstraintViolationException: could not execute statement
via JIRA by Ramin Haeri Azad, 2 years ago
org.hibernate.exception.ConstraintViolationException: could not execute statement
via JIRA by Ramin Haeri Azad, 1 year ago
org.hibernate.exception.ConstraintViolationException: could not execute statement
via JIRA by Ramin Haeri Azad, 2 years ago
org.hibernate.exception.ConstraintViolationException: could not execute statement
via JIRA by Cédric Thiebault, 2 years ago
org.hibernate.exception.ConstraintViolationException: could not execute statement
via JIRA by Cédric Thiebault, 1 year ago
org.hibernate.exception.ConstraintViolationException: could not execute statement
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'opal-keys' for key 'UK_c270jcqlmvthpcasvusahxb7h'	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)	at com.mysql.jdbc.Util.getInstance(Util.java:386)	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1041)	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2825)	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2459)	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2376)	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2360)	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133)	at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:96)	at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:58)	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2989)	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3501)	at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)	at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:393)	at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:227)	at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:207)	at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:191)	at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:321)	at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:286)	at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:192)	at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125)	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:206)	at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:191)	at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)	at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:764)	at org.hibernate.internal.SessionImpl.save(SessionImpl.java:756)	at org.hibernate.internal.SessionImpl.save(SessionImpl.java:752)	at org.obiba.magma.datasource.hibernate.HibernateDatasource.onInitialise(HibernateDatasource.java:216)	at org.obiba.magma.support.AbstractDatasource.initialise(AbstractDatasource.java:92)	at org.obiba.magma.support.Initialisables.initialise(Initialisables.java:14)	at org.obiba.opal.core.service.DefaultIdentifiersTableService.getDatasource(DefaultIdentifiersTableService.java:135)	at org.obiba.opal.core.service.DefaultIdentifiersTableService.getValueTable(DefaultIdentifiersTableService.java:64)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:606)	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)	at com.sun.proxy.$Proxy31.getValueTable(Unknown Source)	at org.obiba.opal.web.FunctionalUnitsResource.getEntitiesTable(FunctionalUnitsResource.java:226)	at org.obiba.opal.web.FunctionalUnitsResource$$FastClassByCGLIB$$91182ae1.invoke()	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)	at org.obiba.opal.web.FunctionalUnitsResource$$EnhancerByCGLIB$$5ffed1d9.getEntitiesTable()	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)	at java.lang.reflect.Method.invoke(Method.java:606)	at org.jboss.resteasy.core.ResourceLocatorInvoker.createResource(ResourceLocatorInvoker.java:81)	at org.jboss.resteasy.core.ResourceLocatorInvoker.createResource(ResourceLocatorInvoker.java:60)	at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:102)	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1329)	at org.obiba.opal.server.httpd.AuthenticationFilter.doFilterInternal(AuthenticationFilter.java:73)	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)	at org.obiba.opal.server.httpd.OpalVersionFilter.doFilterInternal(OpalVersionFilter.java:39)	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1038)	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:374)	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:972)	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)	at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)	at org.eclipse.jetty.server.Server.handle(Server.java:363)	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483)	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:920)	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:982)	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)	at java.lang.Thread.run(Thread.java:744)