From ff3b54a9627a3b01bc14cfc6d318ab22335dfc36 Mon Sep 17 00:00:00 2001 From: Koen Aers Date: Mon, 11 Jan 2016 11:16:48 +0100 Subject: [PATCH] HHH-10430: Comment for class is ignored when using subselect in hibernate mapping - Solution --- .../boot/model/source/internal/hbm/Helper.java | 3 ++- .../source/internal/hbm/InLineViewSourceImpl.java | 11 ++++++++++- .../boot/model/source/internal/hbm/ModelBinder.java | 5 +++-- .../hibernate/boot/model/source/spi/TableSource.java | 2 -- .../model/source/spi/TableSpecificationSource.java | 3 +++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/Helper.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/Helper.java index f324106204..aef4d52a55 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/Helper.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/Helper.java @@ -233,7 +233,8 @@ public class Helper { : tableInformationContainer.getSubselect(), tableInformationContainer.getTable() == null ? inLineViewNameInferrer.inferInLineViewName() - : tableInformationContainer.getTable() + : tableInformationContainer.getTable(), + comment ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/InLineViewSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/InLineViewSourceImpl.java index 046150ec2f..1b614cda9d 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/InLineViewSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/InLineViewSourceImpl.java @@ -18,17 +18,21 @@ public class InLineViewSourceImpl private final String catalogName; private final String selectStatement; private final String logicalName; + private final String comment; public InLineViewSourceImpl( MappingDocument mappingDocument, String schemaName, String catalogName, - String selectStatement, String logicalName) { + String selectStatement, + String logicalName, + String comment) { super( mappingDocument ); this.schemaName = schemaName; this.catalogName = catalogName; this.selectStatement = selectStatement; this.logicalName = logicalName; + this.comment = comment; } @Override @@ -50,4 +54,9 @@ public class InLineViewSourceImpl public String getLogicalName() { return logicalName; } + + @Override + public String getComment() { + return comment; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index 3b213e54ce..7483092546 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -2895,11 +2895,12 @@ public class ModelBinder { if ( isTable ) { final TableSource tableSource = (TableSource) tableSpecSource; table.setRowId( tableSource.getRowId() ); - table.setComment( tableSource.getComment() ); if ( StringHelper.isNotEmpty( tableSource.getCheckConstraint() ) ) { table.addCheckConstraint( tableSource.getCheckConstraint() ); } - } + } + + table.setComment(tableSpecSource.getComment()); mappingDocument.getMetadataCollector().addTableNameBinding( logicalTableName, table ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSource.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSource.java index 489d4ddc58..449e776c7f 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSource.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSource.java @@ -21,7 +21,5 @@ public interface TableSource extends TableSpecificationSource { String getRowId(); - String getComment(); - String getCheckConstraint(); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSpecificationSource.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSpecificationSource.java index 3c6d7a7442..f426acf62e 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSpecificationSource.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/TableSpecificationSource.java @@ -25,4 +25,7 @@ public interface TableSpecificationSource { * @return The catalog name. If {@code null}, the binder will apply the default. */ public String getExplicitCatalogName(); + + public String getComment(); + }