org.springframework.orm.jpa.JpaSystemException

org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement


Samebug tips1

Try downgrading PostgresSQL server to 9.5 or update your PostgresSQL driver to 9.4-1211 with the following command: <postgresql.version>9.4.1211</postgresql.version>

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.


Solutions on the web168

Solution icon of github
via GitHub by aeburriel
, 7 months ago
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of github
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of stackoverflow
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of web
via btsoru.com by Unknown author, 1 year ago
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of stackoverflow
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of stackoverflow
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of github
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of github
via GitHub by aeburriel
, 7 months ago
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of github
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Solution icon of stackoverflow
org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

Stack trace

  • org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:321)[spring-orm-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:33)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at es.uji.apps.par.dao.ButacasDAO.reservaButacas_aroundBody16(ButacasDAO.java:210)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at es.uji.apps.par.dao.ButacasDAO$AjcClosure17.run(ButacasDAO.java:1)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed(AbstractTransactionAspect.aj:59)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.aspectj.AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation(AbstractTransactionAspect.aj:65)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)[spring-tx-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:63)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at es.uji.apps.par.dao.ButacasDAO.reservaButacas(ButacasDAO.java:178)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at es.uji.apps.par.services.ComprasService.registraCompra_aroundBody2(ComprasService.java:121)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at es.uji.apps.par.services.ComprasService$AjcClosure3.run(ComprasService.java:1)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed(AbstractTransactionAspect.aj:59)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.aspectj.AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation(AbstractTransactionAspect.aj:65)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)[spring-tx-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:63)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at es.uji.apps.par.services.ComprasService.registraCompra(ComprasService.java:118)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at es.uji.apps.par.services.ComprasService.registraCompra_aroundBody4(ComprasService.java:151)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at es.uji.apps.par.services.ComprasService$AjcClosure5.run(ComprasService.java:1)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed(AbstractTransactionAspect.aj:59)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.aspectj.AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation(AbstractTransactionAspect.aj:65)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)[spring-tx-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:63)[spring-aspects-3.2.17.RELEASE.jar:3.2.17.RELEASE] at es.uji.apps.par.services.ComprasService.registraCompra(ComprasService.java:143)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at es.uji.apps.par.services.ComprasService.registraCompraTaquilla(ComprasService.java:50)[uji-par-base-0.0.12-SNAPSHOT.jar:na] at es.uji.apps.par.services.rest.CompraResource.compraEntrada(CompraResource.java:212)[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[na:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[na:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[na:1.7.0_79] at java.lang.reflect.Method.invoke(Method.java:606)[na:1.7.0_79] at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)[jersey-servlet-1.17.1.jar:1.17.1] at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)[jersey-servlet-1.17.1.jar:1.17.1] at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)[jersey-servlet-1.17.1.jar:1.17.1] at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)[tomcat-servlet-api-3.0.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)[tomcat7-websocket.jar:7.0.73] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)[tomcat-catalina-7.0.73.jar:7.0.73] at es.uji.apps.par.auth.AuthFilter.doFilter(AuthFilter.java:73)[classes/:na] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)[spring-web-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)[spring-web-3.2.17.RELEASE.jar:3.2.17.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)[tomcat-catalina-7.0.73.jar:7.0.73] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)[tomcat-coyote-7.0.73.jar:7.0.73] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)[tomcat-coyote-7.0.73.jar:7.0.73] at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)[tomcat-coyote-7.0.73.jar:7.0.73] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[na:1.7.0_79] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[na:1.7.0_79] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)[tomcat-coyote-7.0.73.jar:7.0.73] at java.lang.Thread.run(Thread.java:745)[na:1.7.0_79] Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763)[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683)[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1338)[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[na:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[na:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[na:1.7.0_79] at java.lang.reflect.Method.invoke(Method.java:606)[na:1.7.0_79] at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:241)[spring-orm-3.2.17.RELEASE.jar:3.2.17.RELEASE] at com.sun.proxy.$Proxy324.flush(Unknown Source)[na:na] ... 68 more Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:129)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:62)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3124)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3581)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:104)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:465)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:351)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1335)[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final] ... 74 more Caused by: org.postgresql.util.PSQLException: ERROR: llave duplicada viola restricción de unicidad «par_butacas_uk» Detail: Ya existe la llave (sesion_id, localizacion_id, ( CASE WHEN fila IS NULL THEN (id + 1000)::character varying ELSE fila END), ( CASE WHEN numero IS NULL THEN (id + 1000)::character varying ELSE numero END), ( CASE WHEN anulada = true THEN id + 1000 ELSE 1 END))=(919, 1, 12, 1, 1). at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7] at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7] at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7] at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7] at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7] at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7] at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)[c3p0-0.9.1.1.jar:0.9.1.1] at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)[hibernate-core-4.3.11.Final.jar:4.3.11.Final] ... 84 more

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

Once, 1 month ago
Once, 3 months ago
4 times, 3 months ago
18 times, 5 months ago
9 times, 8 months ago
92 more bugmates