0 Replies Latest reply on Feb 12, 2015 6:07 PM by wcomnisky

    Constraint violation when using two schemas and InheritanceType.JOINED

    wcomnisky Newbie

      Hello,

       

      We have the below scenario:

       

      Our abstract superclass, with InheritanceType.JOINED and referenced to the XYZ_SCHEMA.

      @Entity
      @Table(name = "MEDIA", schema = SchemaContant.XYZ_SCHEMA)
      @Inheritance(strategy = InheritanceType.JOINED)
      @DiscriminatorColumn(name = "TYPE")
      @XmlRootElement
      @Audited
      public abstract class Media extends AbstractEntity implements Serializable
      {
         @Column(name = "TYPE")
         private String type;
      
         @Id
         @GeneratedValue(strategy = GenerationType.AUTO)
         @Column(name = "ID", updatable = false, nullable = false)
         private Long id;
      
        // getters, setters, etc..
      }
      

       

       

      And our two concrete classes that extends Media, and referenced to the PUBLIC schema.

      @Entity
      @Table(name = "TRAINING_VIDEO")
      @DiscriminatorValue("TRAINING_VIDEO")
      @XmlRootElement
      @Audited
      public class TrainingVideo extends Media {
      
        @Column(name = "TITLE", nullable=false)
        private String title;
      
        @Column(name = "DESCRIPTION")
        private String description;
      
        @Column(name = "FILE_PATH",nullable=false)
        private String filePath;
      
        @Enumerated(EnumType.STRING)
        @Column(name = "TRAINING_TYPE", nullable=false)
        private TrainingType trainingVideoType;
      
        @ManyToMany(fetch=FetchType.LAZY)
        @JoinTable(name = "TRAININGVIDEO_STORE", joinColumns = { @JoinColumn(name = "TRAININGVIDEO_ID", referencedColumnName = "ID") }, inverseJoinColumns = { @JoinColumn(name = "STORE_ID", referencedColumnName = "ID") })
        private Set<Store> stores = new HashSet<Store>();
      
        // getters, setters, etc..
      }
      

       

      @Entity
      @Table(name = "MESSAGE")
      @DiscriminatorValue("MESSAGE")
      @XmlRootElement
      @Audited
      public class Message extends Media {
      
        @Column(name = "MESSAGE", nullable=false)
        private String message;
      
        @ManyToMany(fetch=FetchType.LAZY)
        @JoinTable(name = "MESSAGE_STORE", joinColumns = { @JoinColumn(name = "MESSAGE_ID", referencedColumnName = "ID") }, inverseJoinColumns = { @JoinColumn(name = "STORE_ID", referencedColumnName = "ID") })
        private Set<Store> stores = new HashSet<Store>();
      
        // getters, setters, etc..
      }
      

       

      As we are using two different schemas, we'll have two different REVINFO tables - one for each schema.

      All tables are created correctly: MEDIA_AUD, TRAINING_VIDEO_AUD, MESSAGE_AUD and STORE_AUD (audited too).

       

      First, I'm creating a new Training Video. All works as expected (all fields are being filled).

      But after this, when I try to create a new Message, I got an exception:

      2015-02-12 20:28:05,187 INFO  [stdout] (default task-119) Hibernate: 
      2015-02-12 20:28:05,187 INFO  [stdout] (default task-119)     insert 
      2015-02-12 20:28:05,188 INFO  [stdout] (default task-119)     into
      2015-02-12 20:28:05,188 INFO  [stdout] (default task-119)         XYZ.MEDIA
      2015-02-12 20:28:05,188 INFO  [stdout] (default task-119)         (REMOVAL_DATE, TYPE, VERSION, ID) 
      2015-02-12 20:28:05,188 INFO  [stdout] (default task-119)     values
      2015-02-12 20:28:05,188 INFO  [stdout] (default task-119)         (?, ?, ?, ?)
      
      
      2015-02-12 20:28:05,189 INFO  [stdout] (default task-119) Hibernate: 
      2015-02-12 20:28:05,189 INFO  [stdout] (default task-119)     insert 
      2015-02-12 20:28:05,189 INFO  [stdout] (default task-119)     into
      2015-02-12 20:28:05,189 INFO  [stdout] (default task-119)         MESSAGE
      2015-02-12 20:28:05,189 INFO  [stdout] (default task-119)         (MESSAGE, ID) 
      2015-02-12 20:28:05,190 INFO  [stdout] (default task-119)     values
      2015-02-12 20:28:05,190 INFO  [stdout] (default task-119)         (?, ?)
      
      
      2015-02-12 20:28:05,190 INFO  [stdout] (default task-119) Hibernate: 
      2015-02-12 20:28:05,190 INFO  [stdout] (default task-119)     insert 
      2015-02-12 20:28:05,191 INFO  [stdout] (default task-119)     into
      2015-02-12 20:28:05,191 INFO  [stdout] (default task-119)         MESSAGE_STORE
      2015-02-12 20:28:05,191 INFO  [stdout] (default task-119)         (MESSAGE_ID, STORE_ID) 
      2015-02-12 20:28:05,191 INFO  [stdout] (default task-119)     values
      2015-02-12 20:28:05,191 INFO  [stdout] (default task-119)         (?, ?)
      
      
      2015-02-12 20:28:05,192 INFO  [stdout] (default task-119) Hibernate: 
      2015-02-12 20:28:05,192 INFO  [stdout] (default task-119)     insert 
      2015-02-12 20:28:05,192 INFO  [stdout] (default task-119)     into
      2015-02-12 20:28:05,192 INFO  [stdout] (default task-119)         REVINFO
      2015-02-12 20:28:05,193 INFO  [stdout] (default task-119)         (REV, REVTSTMP) 
      2015-02-12 20:28:05,193 INFO  [stdout] (default task-119)     values
      2015-02-12 20:28:05,193 INFO  [stdout] (default task-119)         (null, ?)
      
      
      2015-02-12 20:28:05,194 INFO  [stdout] (default task-119) Hibernate: 
      2015-02-12 20:28:05,195 INFO  [stdout] (default task-119)     insert 
      2015-02-12 20:28:05,195 INFO  [stdout] (default task-119)     into
      2015-02-12 20:28:05,195 INFO  [stdout] (default task-119)         XYZ.MEDIA_AUD
      2015-02-12 20:28:05,195 INFO  [stdout] (default task-119)         (REVTYPE, REMOVAL_DATE, TYPE, ID, REV) 
      2015-02-12 20:28:05,196 INFO  [stdout] (default task-119)     values
      2015-02-12 20:28:05,196 INFO  [stdout] (default task-119)         (?, ?, ?, ?, ?)
      
      
      2015-02-12 20:28:05,197 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-119) SQL Error: 23506, SQLState: 23506
      2015-02-12 20:28:05,197 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-119) Referential integrity constraint violation: "FK_8RT4HV7SC30EHWT021D78E7RV: XYZ.MEDIA_AUD FOREIGN KEY(REV) REFERENCES XYZ.REVINFO(REV) (2)"; SQL statement:
      insert into XYZ.MEDIA_AUD (REVTYPE, REMOVAL_DATE, TYPE, ID, REV) values (?, ?, ?, ?, ?) [23506-173]
      2015-02-12 20:28:05,197 INFO  [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-119) HHH000010: On release of batch it still contained JDBC statements
      2015-02-12 20:28:05,198 WARN  [com.arjuna.ats.arjuna] (default task-119) ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffffc0a83801:256247fd:54dd0c20:210, org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization@1e78f3 >: org.hibernate.exception.ConstraintViolationException: could not execute statement
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:129) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:62) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3124) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3581) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:104) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:349) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.envers.internal.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:164) [hibernate-envers-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.envers.internal.synchronization.AuditProcessManager$1.doBeforeTransactionCompletion(AuditProcessManager.java:63) [hibernate-envers-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:715) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:389) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:516) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorNonTrackingImpl.beforeCompletion(SynchronizationCallbackCoordinatorNonTrackingImpl.java:123) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:50) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)
        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:358)
        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:91)
        at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:162)
        at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1166)
        at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)
        at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:93) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:340) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:448)
        at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
        at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
        at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:185)
        at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
        at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73)
        at com.xyz.product.rb.hs.server.rest.MessageEndpoint$$$view119.create(Unknown Source) [classes:]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_25]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_25]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_25]
        at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_25]
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) [resteasy-jaxrs-3.0.10.Final.jar:]
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) [resteasy-jaxrs-3.0.10.Final.jar:]
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) [resteasy-jaxrs-3.0.10.Final.jar:]
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) [resteasy-jaxrs-3.0.10.Final.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.10.Final.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.10.Final.jar:]
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.10.Final.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.10.Final.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.10.Final.jar:]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at com.xyz.rb.hs.server.servlet.upload.CORSFilter.doFilter(CORSFilter.java:28) [classes:]
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
      Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FK_8RT4HV7SC30EHWT021D78E7RV: XYZ.MEDIA_AUD FOREIGN KEY(REV) REFERENCES XYZ.REVINFO(REV) (2)"; SQL statement:
      insert into XYZ.MEDIA_AUD (REVTYPE, REMOVAL_DATE, TYPE, ID, REV) values (?, ?, ?, ?, ?) [23506-173]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
        at org.h2.message.DbException.get(DbException.java:171)
        at org.h2.message.DbException.get(DbException.java:148)
        at org.h2.constraint.ConstraintReferential.checkRowOwnTable(ConstraintReferential.java:368)
        at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:310)
        at org.h2.table.Table.fireConstraints(Table.java:880)
        at org.h2.table.Table.fireAfterRow(Table.java:897)
        at org.h2.command.dml.Insert.insertRows(Insert.java:129)
        at org.h2.command.dml.Insert.update(Insert.java:86)
        at org.h2.command.CommandContainer.update(CommandContainer.java:79)
        at org.h2.command.Command.executeUpdate(Command.java:235)
        at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:154)
        at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:140)
        at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        ... 105 more
      

       

      We're using Wildfly 8.2.0 Final, and hibernate-envers 4.3.8.Final.

       

      Thanks in advance for any help.