77
88import java .io .Serializable ;
99import java .util .Objects ;
10- import java .util .concurrent .CompletionStage ;
11- import jakarta .persistence .CascadeType ;
12- import jakarta .persistence .Entity ;
13- import jakarta .persistence .ForeignKey ;
14- import jakarta .persistence .GeneratedValue ;
15- import jakarta .persistence .Id ;
16- import jakarta .persistence .IdClass ;
17- import jakarta .persistence .Index ;
18- import jakarta .persistence .JoinColumn ;
19- import jakarta .persistence .JoinColumns ;
20- import jakarta .persistence .ManyToOne ;
21- import jakarta .persistence .Table ;
22- import jakarta .persistence .UniqueConstraint ;
2310
2411import org .hibernate .cfg .Configuration ;
2512import org .hibernate .reactive .BaseReactiveTest ;
3219import org .junit .Test ;
3320
3421import io .vertx .ext .unit .TestContext ;
22+ import jakarta .persistence .CascadeType ;
23+ import jakarta .persistence .Entity ;
24+ import jakarta .persistence .ForeignKey ;
25+ import jakarta .persistence .GeneratedValue ;
26+ import jakarta .persistence .Id ;
27+ import jakarta .persistence .IdClass ;
28+ import jakarta .persistence .Index ;
29+ import jakarta .persistence .JoinColumn ;
30+ import jakarta .persistence .JoinColumns ;
31+ import jakarta .persistence .ManyToOne ;
32+ import jakarta .persistence .Table ;
33+ import jakarta .persistence .UniqueConstraint ;
3534
3635import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .SQLSERVER ;
3736import static org .hibernate .tool .schema .JdbcMetadaAccessStrategy .GROUPED ;
@@ -57,19 +56,14 @@ protected Configuration constructConfiguration(String hbm2DdlOption) {
5756 /**
5857 * Test INDIVIDUALLY option when we set the catalog name to the default name
5958 */
60- public static class IndividuallySchemaUpdateWithCatalogTest extends SchemaUpdateSqlServerTestBase {
59+ public static class IndividuallySchemaUpdateWithCatalogTest extends IndividuallySchemaUpdateSqlServerTest {
6160
6261 @ Override
6362 protected Configuration constructConfiguration (String hbm2DdlOption ) {
6463 final Configuration configuration = super .constructConfiguration ( hbm2DdlOption );
6564 configuration .setProperty ( Settings .DEFAULT_CATALOG , DEFAULT_CATALOG_NAME );
6665 return configuration ;
6766 }
68-
69- @ Override
70- public String addCatalog (String name ) {
71- return DEFAULT_CATALOG_NAME + "." + name ;
72- }
7367 }
7468
7569 /**
@@ -88,19 +82,14 @@ protected Configuration constructConfiguration(String hbm2DdlOption) {
8882 /**
8983 * Test GROUPED option when we set the catalog name to default name
9084 */
91- public static class GroupedSchemaUpdateWithCatalogNameTest extends SchemaUpdateSqlServerTestBase {
85+ public static class GroupedSchemaUpdateWithCatalogNameTest extends GroupedSchemaUpdateSqlServerTest {
9286
9387 @ Override
9488 protected Configuration constructConfiguration (String hbm2DdlOption ) {
9589 final Configuration configuration = super .constructConfiguration ( hbm2DdlOption );
9690 configuration .setProperty ( Settings .DEFAULT_CATALOG , DEFAULT_CATALOG_NAME );
9791 return configuration ;
9892 }
99-
100- @ Override
101- public String addCatalog (String name ) {
102- return DEFAULT_CATALOG_NAME + "." + name ;
103- }
10493 }
10594
10695 protected Configuration constructConfiguration (String hbm2DdlOption ) {
@@ -113,36 +102,15 @@ protected Configuration constructConfiguration(String hbm2DdlOption) {
113102 @ Rule
114103 public DatabaseSelectionRule dbRule = DatabaseSelectionRule .runOnlyFor ( SQLSERVER );
115104
116- public String addCatalog (String name ) {
117- return name ;
118- }
119-
120105 @ Before
121106 @ Override
122107 public void before (TestContext context ) {
123108 Configuration createHbm2ddlConf = constructConfiguration ( "create" );
124109 createHbm2ddlConf .addAnnotatedClass ( ASimpleFirst .class );
125110 createHbm2ddlConf .addAnnotatedClass ( AOther .class );
126111
127- test ( context , dropSequenceIfExists ( createHbm2ddlConf )
128- .thenCompose ( ignore -> setupSessionFactory ( createHbm2ddlConf )
129- .thenCompose ( v -> factoryManager .stop () ) ) );
130- }
131-
132- // See HHH-14835: Vert.x throws an exception when the catalog is specified.
133- // Because it happens during schema creation, the error is ignored and the build won't fail
134- // if one of the previous tests has already created the sequence.
135- // This method makes sure that the sequence is deleted if it exists, so that these tests
136- // fail consistently when the wrong ORM version is used.
137- private CompletionStage <Void > dropSequenceIfExists (Configuration createHbm2ddlConf ) {
138- return setupSessionFactory ( createHbm2ddlConf )
139- .thenCompose ( v -> getSessionFactory ()
140- .withTransaction ( (session , transaction ) -> session
141- // No need to add the catalog name because MSSQL doesn't support it
142- .createNativeQuery ( "drop sequence if exists dbo.hibernate_sequence" )
143- .executeUpdate () ) )
144- .handle ( (res , err ) -> null )
145- .thenCompose ( v -> factoryManager .stop () );
112+ test ( context , setupSessionFactory ( createHbm2ddlConf )
113+ .thenCompose ( v -> factoryManager .stop () ) );
146114 }
147115
148116 @ After
0 commit comments