嗨,我一直在尝试调试休眠状态下的constraintViolation出了什么问题。我目前正在运行测试,添加一个图形,删除该图形然后再将其重新添加。我通过PK来存储图形,但是该表上还有一堆外键,我不确定是否违反了什么约束。关于如何查找导致此问题的密钥的任何建议或帮助都很棒
testAddDrawings(mil.navy.spawar.mtc2.c2f.webmap.dataservice.test.postgres.TestDrawingRepo) Time elapsed: 0.012 sec <<< FAILURE!
org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2198)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1927)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:561)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:419)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:365)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3136)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3651)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:90)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
at org.hibernate.engine.spi.ActionQueue.executeInserts(ActionQueue.java:461)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:258)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:359)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:292)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:200)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:131)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:97)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:678)
at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:670)
at org.hibernate.engine.spi.CascadingActions$5.cascade(CascadingActions.java:219)
at org.hibernate.engine.internal.Cascade.cascadeToOne(Cascade.java:471)
at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:396)
at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:197)
at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.internal.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:455)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:200)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:131)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:97)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:678)
at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:670)
at org.hibernate.engine.spi.CascadingActions$5.cascade(CascadingActions.java:219)
at org.hibernate.engine.internal.Cascade.cascadeToOne(Cascade.java:471)
at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:396)
at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:197)
at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.internal.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:455)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:200)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:143)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:97)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:678)
at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:670)
at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:665)
at mil.navy.spawar.mtc2.c2f.webmap.dataservice.repository.postgres.repository.PostgresDrawingRepo.addDrawings(PostgresDrawingRepo.java:91)
at mil.navy.spawar.mtc2.c2f.webmap.dataservice.test.postgres.TestDrawingRepo.testAddDrawings(TestDrawingRepo.java:58)
答案 0 :(得分:0)
在调试日志的上方,测试用例的上方查看错误发生时的错误消息,因此,如果滚动浏览所有日志记录,则可以专门跟踪引起问题的外键或主键< / p>