From 31377b1423a2c6737f76a5fe33f09743e8a578fb Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 28 Jan 2020 22:37:40 +0100 Subject: [PATCH] Register JPA embeddable types properly, allow access to functions in registry and fix AttributeClassifications --- .../java/org/hibernate/metamodel/AttributeClassification.java | 4 ++-- .../org/hibernate/metamodel/internal/MetadataContext.java | 1 + .../org/hibernate/query/sqm/function/SqmFunctionRegistry.java | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/AttributeClassification.java b/hibernate-core/src/main/java/org/hibernate/metamodel/AttributeClassification.java index ee21130b91..0a5aa592ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/AttributeClassification.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/AttributeClassification.java @@ -13,9 +13,9 @@ public enum AttributeClassification { EMBEDDED( PersistentAttributeType.EMBEDDED ), ANY( null ), ONE_TO_ONE( PersistentAttributeType.ONE_TO_ONE ), - MANY_TO_ONE( PersistentAttributeType.EMBEDDED ), + MANY_TO_ONE( PersistentAttributeType.MANY_TO_ONE ), ELEMENT_COLLECTION( PersistentAttributeType.ELEMENT_COLLECTION ), - ONE_TO_MANY( PersistentAttributeType.MANY_TO_ONE ), + ONE_TO_MANY( PersistentAttributeType.ONE_TO_MANY ), MANY_TO_MANY( PersistentAttributeType.MANY_TO_MANY ); private final PersistentAttributeType jpaClassification; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java index 7ec617119d..93c3ab8b14 100755 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java @@ -344,6 +344,7 @@ public class MetadataContext { } ( ( AttributeContainer) embeddable ).getInFlightAccess().finishUp(); + embeddables.put( embeddable.getJavaType(), embeddable ); if ( staticMetamodelScanEnabled ) { populateStaticMetamodel( embeddable ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/function/SqmFunctionRegistry.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/function/SqmFunctionRegistry.java index 9ff841da58..9ffaa73ef6 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/function/SqmFunctionRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/function/SqmFunctionRegistry.java @@ -36,6 +36,10 @@ public class SqmFunctionRegistry { log.tracef( "SqmFunctionRegistry created" ); } + public Map getFunctions() { + return functionMap; + } + /** * Find a SqmFunctionTemplate by name. Returns {@code null} if * no such function is found.