16
16
import org .hibernate .boot .model .relational .InitCommand ;
17
17
import org .hibernate .boot .model .relational .QualifiedName ;
18
18
import org .hibernate .boot .model .relational .QualifiedNameParser ;
19
+ import org .hibernate .boot .model .relational .QualifiedTableName ;
19
20
import org .hibernate .boot .model .relational .SqlStringGenerationContext ;
20
21
import org .hibernate .boot .spi .MetadataImplementor ;
21
22
import org .hibernate .dialect .Dialect ;
@@ -48,10 +49,11 @@ public String[] getSqlCreateStrings(
48
49
);
49
50
50
51
try {
52
+ String formattedTableName = context .format ( tableName );
51
53
StringBuilder buf =
52
54
new StringBuilder ( tableCreateString ( table .hasPrimaryKey () ) )
53
55
.append ( ' ' )
54
- .append ( context . format ( tableName ) )
56
+ .append ( formattedTableName )
55
57
.append ( " (" );
56
58
57
59
@@ -162,7 +164,7 @@ public String[] getSqlCreateStrings(
162
164
List <String > sqlStrings = new ArrayList <>();
163
165
sqlStrings .add ( buf .toString () );
164
166
165
- applyComments ( table , tableName , sqlStrings );
167
+ applyComments ( table , formattedTableName , sqlStrings );
166
168
167
169
applyInitCommands ( table , sqlStrings , context );
168
170
@@ -173,15 +175,32 @@ public String[] getSqlCreateStrings(
173
175
}
174
176
}
175
177
176
- protected void applyComments (Table table , QualifiedName tableName , List <String > sqlStrings ) {
178
+ /**
179
+ * @param table The table.
180
+ * @param tableName The qualified table name.
181
+ * @param sqlStrings The list of SQL strings to add comments to.
182
+ * @deprecated Use {@link #applyComments(Table, String, List)} instead.
183
+ */
184
+ // For backwards compatibility with subclasses that happen to call this method...
185
+ @ Deprecated
186
+ protected void applyComments (Table table , QualifiedTableName tableName , List <String > sqlStrings ) {
187
+ applyComments ( table , tableName .toString (), sqlStrings );
188
+ }
189
+
190
+ /**
191
+ * @param table The table.
192
+ * @param formattedTableName The formatted table name.
193
+ * @param sqlStrings The list of SQL strings to add comments to.
194
+ */
195
+ protected void applyComments (Table table , String formattedTableName , List <String > sqlStrings ) {
177
196
if ( dialect .supportsCommentOn () ) {
178
197
if ( table .getComment () != null ) {
179
- sqlStrings .add ( "comment on table " + tableName + " is '" + table .getComment () + "'" );
198
+ sqlStrings .add ( "comment on table " + formattedTableName + " is '" + table .getComment () + "'" );
180
199
}
181
200
for ( Column column : table .getColumns () ) {
182
201
String columnComment = column .getComment ();
183
202
if ( columnComment != null ) {
184
- sqlStrings .add ( "comment on column " + tableName + '.' + column .getQuotedName ( dialect ) + " is '" + columnComment + "'" );
203
+ sqlStrings .add ( "comment on column " + formattedTableName + '.' + column .getQuotedName ( dialect ) + " is '" + columnComment + "'" );
185
204
}
186
205
}
187
206
}
0 commit comments