test/entities/TestDatabaseApplication.java
/**
     * Deletes all non-Envers entities from the In-Memory Database after every
     * successful Test.
     *
     * @throws Exception
     */
Deletes all non-Envers entities from the In-Memory Database after every
successful Test.

@throws Exception
Deletes all non - Envers entities from the In - Memory Database after every successful Test . @throws Exception
@After
    public void tearDown() throws Exception {
        JPA.withTransaction(() -> {
            JPA.em().createNativeQuery("SET REFERENTIAL_INTEGRITY FALSE").executeUpdate();
            JPA.em().getMetamodel().getEntities().stream().map(EntityType::getName).forEach(entity -> {
                if(!entity.contains("Audit") && !entity.contains("DefaultRevisionEntity")) {
                    final List items = JPA.em().createQuery("from " + entity).getResultList();
                    Logger.warn("Will delete {} items from {}.", items.size(), entity);
                    items.stream().forEach(o -> JPA.em().remove(o));
                }
            });
            JPA.em().createNativeQuery("SET REFERENTIAL_INTEGRITY TRUE").executeUpdate();
        });
    }
@ After public void tearDown ( ) throws Exception { JPA . withTransaction ( ( ) -> { JPA . em ( ) . createNativeQuery ( "SET REFERENTIAL_INTEGRITY FALSE" ) . executeUpdate ( ) ; JPA . em ( ) . getMetamodel ( ) . getEntities ( ) . stream ( ) . map ( EntityType :: getName ) . forEach ( entity -> { if ( ! entity . contains ( "Audit" ) && ! entity . contains ( "DefaultRevisionEntity" ) ) { final List items = JPA . em ( ) . createQuery ( "from " + entity ) . getResultList ( ) ; Logger . warn ( "Will delete {} items from {}." , items . size ( ) , entity ) ; items . stream ( ) . forEach ( o -> JPA . em ( ) . remove ( o ) ) ; } } ) ; JPA . em ( ) . createNativeQuery ( "SET REFERENTIAL_INTEGRITY TRUE" ) . executeUpdate ( ) ; } ) ; }
Deletes all non-Envers entities from the In-Memory Database after every
 successful Test.
Deletes all non - Envers entities from the In - Memory Database after every successful Test .
// Filter our Envers Tables