7
7
8
8
import java .io .Serializable ;
9
9
import 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 ;
23
10
24
11
import org .hibernate .cfg .Configuration ;
25
12
import org .hibernate .reactive .BaseReactiveTest ;
32
19
import org .junit .Test ;
33
20
34
21
import 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 ;
35
34
36
35
import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .SQLSERVER ;
37
36
import static org .hibernate .tool .schema .JdbcMetadaAccessStrategy .GROUPED ;
@@ -57,19 +56,14 @@ protected Configuration constructConfiguration(String hbm2DdlOption) {
57
56
/**
58
57
* Test INDIVIDUALLY option when we set the catalog name to the default name
59
58
*/
60
- public static class IndividuallySchemaUpdateWithCatalogTest extends SchemaUpdateSqlServerTestBase {
59
+ public static class IndividuallySchemaUpdateWithCatalogTest extends IndividuallySchemaUpdateSqlServerTest {
61
60
62
61
@ Override
63
62
protected Configuration constructConfiguration (String hbm2DdlOption ) {
64
63
final Configuration configuration = super .constructConfiguration ( hbm2DdlOption );
65
64
configuration .setProperty ( Settings .DEFAULT_CATALOG , DEFAULT_CATALOG_NAME );
66
65
return configuration ;
67
66
}
68
-
69
- @ Override
70
- public String addCatalog (String name ) {
71
- return DEFAULT_CATALOG_NAME + "." + name ;
72
- }
73
67
}
74
68
75
69
/**
@@ -88,19 +82,14 @@ protected Configuration constructConfiguration(String hbm2DdlOption) {
88
82
/**
89
83
* Test GROUPED option when we set the catalog name to default name
90
84
*/
91
- public static class GroupedSchemaUpdateWithCatalogNameTest extends SchemaUpdateSqlServerTestBase {
85
+ public static class GroupedSchemaUpdateWithCatalogNameTest extends GroupedSchemaUpdateSqlServerTest {
92
86
93
87
@ Override
94
88
protected Configuration constructConfiguration (String hbm2DdlOption ) {
95
89
final Configuration configuration = super .constructConfiguration ( hbm2DdlOption );
96
90
configuration .setProperty ( Settings .DEFAULT_CATALOG , DEFAULT_CATALOG_NAME );
97
91
return configuration ;
98
92
}
99
-
100
- @ Override
101
- public String addCatalog (String name ) {
102
- return DEFAULT_CATALOG_NAME + "." + name ;
103
- }
104
93
}
105
94
106
95
protected Configuration constructConfiguration (String hbm2DdlOption ) {
@@ -113,36 +102,15 @@ protected Configuration constructConfiguration(String hbm2DdlOption) {
113
102
@ Rule
114
103
public DatabaseSelectionRule dbRule = DatabaseSelectionRule .runOnlyFor ( SQLSERVER );
115
104
116
- public String addCatalog (String name ) {
117
- return name ;
118
- }
119
-
120
105
@ Before
121
106
@ Override
122
107
public void before (TestContext context ) {
123
108
Configuration createHbm2ddlConf = constructConfiguration ( "create" );
124
109
createHbm2ddlConf .addAnnotatedClass ( ASimpleFirst .class );
125
110
createHbm2ddlConf .addAnnotatedClass ( AOther .class );
126
111
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 () ) );
146
114
}
147
115
148
116
@ After
0 commit comments