Skip to content

Commit 8dbbb40

Browse files
cigalybeikov
authored andcommitted
HHH-18218 - Improved type resolving when tuple element implements SqmExpressibleAccessor
1 parent f63f15b commit 8dbbb40

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowTransformerConstructorImpl.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import java.lang.reflect.Constructor;
1515
import java.util.List;
1616

17+
import org.hibernate.query.sqm.SqmExpressible;
18+
import org.hibernate.query.sqm.tree.SqmExpressibleAccessor;
19+
1720
/**
1821
* {@link RowTransformer} instantiating an arbitrary class
1922
*
@@ -30,7 +33,7 @@ public RowTransformerConstructorImpl(Class<T> type, TupleMetadata tupleMetadata)
3033
final List<TupleElement<?>> elements = tupleMetadata.getList();
3134
final Class<?>[] sig = new Class[elements.size()];
3235
for (int i = 0; i < elements.size(); i++) {
33-
sig[i] = elements.get(i).getJavaType();
36+
sig[i] = resolveElementJavaType( elements.get( i ) );
3437
}
3538
try {
3639
constructor = type.getDeclaredConstructor( sig );
@@ -42,6 +45,17 @@ public RowTransformerConstructorImpl(Class<T> type, TupleMetadata tupleMetadata)
4245
}
4346
}
4447

48+
private static Class<?> resolveElementJavaType(TupleElement<?> element) {
49+
if ( element instanceof SqmExpressibleAccessor ) {
50+
SqmExpressible expressible = ( (SqmExpressibleAccessor) element ).getExpressible();
51+
if ( expressible != null ) {
52+
return expressible.getExpressibleJavaType().getJavaTypeClass();
53+
}
54+
}
55+
56+
return element.getJavaType();
57+
}
58+
4559
@Override
4660
public T transformRow(Object[] row) {
4761
try {

0 commit comments

Comments
 (0)