@@ -55,14 +55,22 @@ public SchemaManager forSchemaAndCatalog(String schemaName, String catalogName)
55
55
return new SchemaManagerImpl ( sessionFactory , metadata , schemaName , catalogName );
56
56
}
57
57
58
+ private void addSchemaAndCatalog (Map <String , Object > properties ) {
59
+ if ( schemaName != null ) {
60
+ properties .put ( AvailableSettings .DEFAULT_SCHEMA , schemaName );
61
+ }
62
+ if ( catalogName != null ) {
63
+ properties .put ( AvailableSettings .DEFAULT_CATALOG , catalogName );
64
+ }
65
+ }
66
+
58
67
@ Override
59
68
public void exportMappedObjects (boolean createSchemas ) {
60
69
Map <String , Object > properties = new HashMap <>( sessionFactory .getProperties () );
61
70
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_DATABASE_ACTION , Action .CREATE_ONLY );
62
71
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_SCRIPTS_ACTION , Action .NONE );
63
72
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_CREATE_SCHEMAS , createSchemas );
64
- properties .put ( AvailableSettings .DEFAULT_SCHEMA , schemaName );
65
- properties .put ( AvailableSettings .DEFAULT_CATALOG , catalogName );
73
+ addSchemaAndCatalog ( properties );
66
74
SchemaManagementToolCoordinator .process (
67
75
metadata ,
68
76
sessionFactory .getServiceRegistry (),
@@ -77,8 +85,7 @@ public void dropMappedObjects(boolean dropSchemas) {
77
85
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_DATABASE_ACTION , Action .DROP );
78
86
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_SCRIPTS_ACTION , Action .NONE );
79
87
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_CREATE_SCHEMAS , dropSchemas );
80
- properties .put ( AvailableSettings .DEFAULT_SCHEMA , schemaName );
81
- properties .put ( AvailableSettings .DEFAULT_CATALOG , catalogName );
88
+ addSchemaAndCatalog ( properties );
82
89
SchemaManagementToolCoordinator .process (
83
90
metadata ,
84
91
sessionFactory .getServiceRegistry (),
@@ -93,8 +100,7 @@ public void validateMappedObjects() {
93
100
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_DATABASE_ACTION , Action .VALIDATE );
94
101
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_SCRIPTS_ACTION , Action .NONE );
95
102
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_CREATE_SCHEMAS , false );
96
- properties .put ( AvailableSettings .DEFAULT_SCHEMA , schemaName );
97
- properties .put ( AvailableSettings .DEFAULT_CATALOG , catalogName );
103
+ addSchemaAndCatalog ( properties );
98
104
SchemaManagementToolCoordinator .process (
99
105
metadata ,
100
106
sessionFactory .getServiceRegistry (),
@@ -108,8 +114,7 @@ public void truncateMappedObjects() {
108
114
Map <String , Object > properties = new HashMap <>( sessionFactory .getProperties () );
109
115
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_DATABASE_ACTION , Action .TRUNCATE );
110
116
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_SCRIPTS_ACTION , Action .NONE );
111
- properties .put ( AvailableSettings .DEFAULT_SCHEMA , schemaName );
112
- properties .put ( AvailableSettings .DEFAULT_CATALOG , catalogName );
117
+ addSchemaAndCatalog ( properties );
113
118
SchemaManagementToolCoordinator .process (
114
119
metadata ,
115
120
sessionFactory .getServiceRegistry (),
@@ -123,8 +128,7 @@ public void populate() {
123
128
Map <String , Object > properties = new HashMap <>( sessionFactory .getProperties () );
124
129
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_DATABASE_ACTION , Action .POPULATE );
125
130
properties .put ( AvailableSettings .JAKARTA_HBM2DDL_SCRIPTS_ACTION , Action .NONE );
126
- properties .put ( AvailableSettings .DEFAULT_SCHEMA , schemaName );
127
- properties .put ( AvailableSettings .DEFAULT_CATALOG , catalogName );
131
+ addSchemaAndCatalog ( properties );
128
132
SchemaManagementToolCoordinator .process (
129
133
metadata ,
130
134
sessionFactory .getServiceRegistry (),
0 commit comments