org.hibernate.exception.ConstraintViolationException

could not delete: [com.springsource.insight.repo.resource.persist.PersistedApplicationResource#189]

Samebug tips1

Check if you're not creating unused SQL entities, as it might cause this exception.


rafaelrafael

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

Solutions on the web851

  • via Unknown by Bruce Edge,
  • via Unknown by Bruce Edge,
  • Stack trace

    • org.hibernate.exception.ConstraintViolationException: could not delete: [com.springsource.insight.repo.resource.persist.PersistedApplicationResource#189] at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:637) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:102) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:368) at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy68.findResource(Unknown Source) at com.springsource.insight.repo.resource.persist.PersistedResourceRepo.removeResource(PersistedResourceRepo.java:175) at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source) 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:309) 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.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy71.removeResource(Unknown Source) at com.springsource.insight.repo.purge.IncrementalPurgerImpl.purgeResources(IncrementalPurgerImpl.java:86) 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:309) 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.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy78.purgeResources(Unknown Source) at com.springsource.insight.repo.purge.PurgeServiceImpl.purgeResources(PurgeServiceImpl.java:145) at com.springsource.insight.repo.purge.PurgeServiceImpl.purgeData(PurgeServiceImpl.java:121) at com.springsource.insight.repo.purge.PurgeServiceImpl.purgeExpiredData(PurgeServiceImpl.java:87) at com.springsource.insight.repo.purge.PurgeServiceImpl$2.run(PurgeServiceImpl.java:177) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) Caused by: org.hibernate.exception.ConstraintViolationException: could not delete: [com.springsource.insight.repo.resource.persist.PersistedApplicationResource#189] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2710) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2893) at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:189) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64) at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1185) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1261) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:274) at com.springsource.insight.repo.resource.persist.JpaResourceDAO.getResource(JpaResourceDAO.java:74) at com.springsource.insight.repo.resource.persist.JpaResourceDAO.findResource(JpaResourceDAO.java:63) at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source) 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:309) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) ... 35 more Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FK_RESOURCES_APPLICATION: PUBLIC.RESOURCES FOREIGN KEY(APPLICATION) REFERENCES PUBLIC.RESOURCES(ID)"; SQL statement: delete from resources where id=? and version=? [23003-147] at org.h2.message.DbException.getJdbcSQLException(DbException.java:327) at org.h2.message.DbException.get(DbException.java:167) at org.h2.message.DbException.get(DbException.java:144) at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:382) at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:399) at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:275) at org.h2.table.Table.fireConstraints(Table.java:812) at org.h2.table.Table.fireAfterRow(Table.java:829) at org.h2.command.dml.Delete.update(Delete.java:80) at org.h2.command.CommandContainer.update(CommandContainer.java:69) at org.h2.command.Command.executeUpdate(Command.java:201) at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:143) at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:129) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2692) ... 55 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

    j.kienzlej.kienzle
    2 times, last one
    tvrmsmithtvrmsmith
    Once,
    Andreas HäberAndreas Häber
    Once,
    Victor_ITVictor_IT
    3 times, last one
    batwalrus76batwalrus76
    3 times, last one
    143 more bugmates