Я определил класс сущности ExportRecordStatus, имеющий Integer Id, как один из атрибутов.
ExportRecordStatus определяется со всеми значениями, и при сохранении он сохраняется для одной сущности, но не выполняется для нескольких сущностей.
exportRecordStatusList имеет следующие записи:
[ExportRecordStatus
[Id=null, runId=55801, mdmItemId=1111, endPointItemId=null, statusTime=xxxxx, endPointName=xxx, status=ERROR, detailStatus=xxxx, endPointResponseCode=null],
ExportRecordStatus
[Id=null, runId=55801, mdmItemId=2222, endPointItemId=null, statusTime=xxxx, endPointName=xxx, status=ERROR, detailStatus=xxx, endPointResponseCode=null]
]
Id being primary key.
org.springframework.dao.DataIntegrityViolationException: не удалось выполнить инструкцию;SQL [н / п];ограничение [ноль];вложенное исключение - org.hibernate.exception.ConstraintViolationException: не удалось выполнить инструкцию
сущность определена так, как с атрибутом Id помечено следующее:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "qconn_ers_id")
@SequenceGenerator(name="qconn_ers_id", sequenceName = "qconn_ers_id", allocationSize=1)
@Column(name = "ERS_ID", updatable = false, nullable = false)
pdefined Integer Id;
Я определилКласс хранилища выглядит следующим образом:
public interface ExportRecordStatusCRUDRepository extends CrudRepository<ExportRecordStatus, Integer> {}
При вызове одного объекта. Он работает для одного объекта.
exportRecordStatusCRUDRepository.save (exportRecordStatus);
, но в случае нескольких объектов происходит сбой и возникает исключение.
Сохранение должно быть успешным, для идентификатора должно быть уникальное значение для каждого объекта ExportRecordStatus.
Полный стекКопируется ниже -
2019-02-19 14:23:56,244 ERROR c.i.m.c.a.p.AllExceptionsProcessor [Camel (camel-1) thread #6 - Threads] STOPPING the processing of becuase of exception could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statementStackTrace org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy118.save(Unknown Source) at com.ibm.mdm.camel.adobe.processor.WriteResponseToDBProcessor.process(WriteResponseToDBProcessor.java:72) at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:76)at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:76)at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.access$100(Pipeline.java:43)
at org.apache.camel.processor.Pipeline$1.done(Pipeline.java:157)
at org.apache.camel.processor.ThreadsProcessor$ProcessCall.run(ThreadsProcessor.java:87)at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522)
at java.util.concurrent.FutureTask.run(FutureTask.java:277)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:785)
Нужна помощь по этому вопросу.Заранее спасибо.