Skip to content

Commit ff3b54a

Browse files
koentsjedreab8
authored andcommitted
HHH-10430: Comment for class is ignored when using subselect in hibernate mapping - Solution
1 parent fd21be8 commit ff3b54a

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/Helper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ public static TableSpecificationSource createTableSource(
233233
: tableInformationContainer.getSubselect(),
234234
tableInformationContainer.getTable() == null
235235
? inLineViewNameInferrer.inferInLineViewName()
236-
: tableInformationContainer.getTable()
236+
: tableInformationContainer.getTable(),
237+
comment
237238
);
238239
}
239240
}

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/InLineViewSourceImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,21 @@ public class InLineViewSourceImpl
1818
private final String catalogName;
1919
private final String selectStatement;
2020
private final String logicalName;
21+
private final String comment;
2122

2223
public InLineViewSourceImpl(
2324
MappingDocument mappingDocument,
2425
String schemaName,
2526
String catalogName,
26-
String selectStatement, String logicalName) {
27+
String selectStatement,
28+
String logicalName,
29+
String comment) {
2730
super( mappingDocument );
2831
this.schemaName = schemaName;
2932
this.catalogName = catalogName;
3033
this.selectStatement = selectStatement;
3134
this.logicalName = logicalName;
35+
this.comment = comment;
3236
}
3337

3438
@Override
@@ -50,4 +54,9 @@ public String getSelectStatement() {
5054
public String getLogicalName() {
5155
return logicalName;
5256
}
57+
58+
@Override
59+
public String getComment() {
60+
return comment;
61+
}
5362
}

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,11 +2895,12 @@ public MetadataBuildingContext getBuildingContext() {
28952895
if ( isTable ) {
28962896
final TableSource tableSource = (TableSource) tableSpecSource;
28972897
table.setRowId( tableSource.getRowId() );
2898-
table.setComment( tableSource.getComment() );
28992898
if ( StringHelper.isNotEmpty( tableSource.getCheckConstraint() ) ) {
29002899
table.addCheckConstraint( tableSource.getCheckConstraint() );
29012900
}
2902-
}
2901+
}
2902+
2903+
table.setComment(tableSpecSource.getComment());
29032904

29042905
mappingDocument.getMetadataCollector().addTableNameBinding( logicalTableName, table );
29052906

hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSource.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@ public interface TableSource extends TableSpecificationSource {
2121

2222
String getRowId();
2323

24-
String getComment();
25-
2624
String getCheckConstraint();
2725
}

hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSpecificationSource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ public interface TableSpecificationSource {
2525
* @return The catalog name. If {@code null}, the binder will apply the default.
2626
*/
2727
public String getExplicitCatalogName();
28+
29+
public String getComment();
30+
2831
}

0 commit comments

Comments
 (0)