mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-13 14:44:48 +00:00
fix logic for interpreting HQL literal enum values
Note that this feature still doesn't work because we still can't get a MappingModelExpressable from an SqmEnumLiteral.
This commit is contained in:
parent
e808041477
commit
3545de74ea
@ -196,6 +196,7 @@ public SemanticPathPart resolvePathPart(
|
|||||||
if ( splitPosition > 0 ) {
|
if ( splitPosition > 0 ) {
|
||||||
final String prefix = pathSoFar.substring( 0, splitPosition );
|
final String prefix = pathSoFar.substring( 0, splitPosition );
|
||||||
final String terminal = pathSoFar.substring( splitPosition + 1 );
|
final String terminal = pathSoFar.substring( splitPosition + 1 );
|
||||||
|
//TODO: try interpreting paths of form foo.bar.Foo.Bar as foo.bar.Foo$Bar
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Class<?> namedClass = creationContext
|
final Class<?> namedClass = creationContext
|
||||||
@ -206,6 +207,16 @@ public SemanticPathPart resolvePathPart(
|
|||||||
final JavaTypeDescriptorRegistry javaTypeDescriptorRegistry = creationContext.getJpaMetamodel()
|
final JavaTypeDescriptorRegistry javaTypeDescriptorRegistry = creationContext.getJpaMetamodel()
|
||||||
.getTypeConfiguration()
|
.getTypeConfiguration()
|
||||||
.getJavaTypeDescriptorRegistry();
|
.getJavaTypeDescriptorRegistry();
|
||||||
|
|
||||||
|
if ( namedClass.isEnum() ) {
|
||||||
|
return new SqmEnumLiteral(
|
||||||
|
Enum.valueOf( (Class) namedClass, terminal ),
|
||||||
|
(EnumJavaTypeDescriptor<?>) javaTypeDescriptorRegistry.resolveDescriptor( namedClass ),
|
||||||
|
terminal,
|
||||||
|
creationContext.getNodeBuilder()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Field referencedField = namedClass.getDeclaredField( terminal );
|
final Field referencedField = namedClass.getDeclaredField( terminal );
|
||||||
if ( referencedField != null ) {
|
if ( referencedField != null ) {
|
||||||
@ -217,18 +228,6 @@ public SemanticPathPart resolvePathPart(
|
|||||||
}
|
}
|
||||||
catch (Exception ignore) {
|
catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( namedClass.isEnum() ) {
|
|
||||||
//noinspection unchecked
|
|
||||||
final Enum referencedEnum = Enum.valueOf( (Class) namedClass, terminal );
|
|
||||||
//noinspection unchecked
|
|
||||||
return new SqmEnumLiteral(
|
|
||||||
referencedEnum,
|
|
||||||
(EnumJavaTypeDescriptor) javaTypeDescriptorRegistry.resolveDescriptor( namedClass ),
|
|
||||||
terminal,
|
|
||||||
creationContext.getNodeBuilder()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ignore) {
|
catch (Exception ignore) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user