From c16731d14a3c3188a4797f3ac2c4d7ea6d143cfb Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Wed, 1 Sep 2021 18:02:42 +0200 Subject: [PATCH] Cleanup docs, implement appendHqlString for DiscriminatorSqmPath and fix MapMember type --- .../embeddable-type-override-mapping-example.sql | 12 ++++++------ .../metamodel/internal/AttributeFactory.java | 5 ++++- .../model/domain/internal/DiscriminatorSqmPath.java | 4 +++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/documentation/src/main/asciidoc/userguide/chapters/domain/extras/embeddable/embeddable-type-override-mapping-example.sql b/documentation/src/main/asciidoc/userguide/chapters/domain/extras/embeddable/embeddable-type-override-mapping-example.sql index bc87dbbf1d..b980e9da67 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/domain/extras/embeddable/embeddable-type-override-mapping-example.sql +++ b/documentation/src/main/asciidoc/userguide/chapters/domain/extras/embeddable/embeddable-type-override-mapping-example.sql @@ -1,20 +1,20 @@ create table Book ( id bigint not null, author varchar(255), - ebook_publisher_name varchar(255), - paper_back_publisher_name varchar(255), + ebook_pub_name varchar(255), + paper_back_pub_name varchar(255), title varchar(255), - ebook_publisher_country_id bigint, - paper_back_publisher_country_id bigint, + ebook_pub_country_id bigint, + paper_back_pub_country_id bigint, primary key (id) ) alter table Book add constraint FKm39ibh5jstybnslaoojkbac2g - foreign key (ebook_publisher_country_id) + foreign key (ebook_pub_country_id) references Country alter table Book add constraint FK7kqy9da323p7jw7wvqgs6aek7 - foreign key (paper_back_publisher_country_id) + foreign key (paper_back_pub_country_id) references Country \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java index 7f13282a2e..470ae85473 100755 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java @@ -589,7 +589,10 @@ public class AttributeFactory { final EmbeddableDomainType ownerType = (EmbeddableDomainType) attributeContext.getOwnerType(); if ( ownerType.getRepresentationStrategy().getMode() == RepresentationMode.MAP ) { - return new MapMember( attributeContext.getPropertyMapping().getName(), ownerType.getExpressableJavaTypeDescriptor().getJavaTypeClass() ); + return new MapMember( + attributeContext.getPropertyMapping().getName(), + attributeContext.getPropertyMapping().getType().getReturnedClass() + ); } else { return ownerType.getRepresentationStrategy() diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/DiscriminatorSqmPath.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/DiscriminatorSqmPath.java index a5e1c93903..14647b4c41 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/DiscriminatorSqmPath.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/DiscriminatorSqmPath.java @@ -72,7 +72,9 @@ public class DiscriminatorSqmPath extends AbstractSqmPath implements SelfInterpr @Override public void appendHqlString(StringBuilder sb) { - // todo (6.0) : no idea + sb.append( "type(" ); + getLhs().appendHqlString( sb ); + sb.append( ')' ); } @Override