|
7 | 7 |
|
8 | 8 | import java.io.Serializable;
|
9 | 9 | import java.util.Objects;
|
| 10 | +import java.util.concurrent.CompletionStage; |
10 | 11 | import javax.persistence.CascadeType;
|
11 | 12 | import javax.persistence.Entity;
|
12 | 13 | import javax.persistence.ForeignKey;
|
@@ -80,8 +81,24 @@ public void before(TestContext context) {
|
80 | 81 | createHbm2ddlConf.addAnnotatedClass( ASimpleFirst.class );
|
81 | 82 | createHbm2ddlConf.addAnnotatedClass( AOther.class );
|
82 | 83 |
|
83 |
| - test( context, setupSessionFactory( createHbm2ddlConf ) |
84 |
| - .thenCompose( v -> factoryManager.stop() ) ); |
| 84 | + test( context, dropSequenceIfExists( createHbm2ddlConf ) |
| 85 | + .thenCompose( ignore -> setupSessionFactory( createHbm2ddlConf ) |
| 86 | + .thenCompose( v -> factoryManager.stop() ) ) ); |
| 87 | + } |
| 88 | + |
| 89 | + // See HHH-14835: Vert.x throws an exception when the catalog is specified. |
| 90 | + // Because it happens during schema creation, the error is ignored and the build won't fail |
| 91 | + // if one of the previous tests has already created the sequence. |
| 92 | + // This method make sure that the sequence is deleted if it exists, so that these tests |
| 93 | + // fail consistently when the wrong ORM version is used. |
| 94 | + private CompletionStage<Void> dropSequenceIfExists(Configuration createHbm2ddlConf) { |
| 95 | + return setupSessionFactory( createHbm2ddlConf ) |
| 96 | + .thenCompose( v -> getSessionFactory() |
| 97 | + .withTransaction( (session, transaction) -> session |
| 98 | + .createNativeQuery( "drop sequence if exists dbo.hibernate_sequence" ) |
| 99 | + .executeUpdate() ) ) |
| 100 | + .handle( (res, err) -> null ) |
| 101 | + .thenCompose( v -> factoryManager.stop() ); |
85 | 102 | }
|
86 | 103 |
|
87 | 104 | @After
|
|
0 commit comments