HHH-18218 - Improved type resolving when tuple element implements SqmExpressibleAccessor
This commit is contained in:
parent
9e13bd0c48
commit
4c8e72c5ec
|
@ -14,6 +14,9 @@ import org.hibernate.sql.results.spi.RowTransformer;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.query.sqm.SqmExpressible;
|
||||||
|
import org.hibernate.query.sqm.tree.SqmExpressibleAccessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link RowTransformer} instantiating an arbitrary class
|
* {@link RowTransformer} instantiating an arbitrary class
|
||||||
*
|
*
|
||||||
|
@ -28,7 +31,7 @@ public class RowTransformerConstructorImpl<T> implements RowTransformer<T> {
|
||||||
final List<TupleElement<?>> elements = tupleMetadata.getList();
|
final List<TupleElement<?>> elements = tupleMetadata.getList();
|
||||||
final Class<?>[] sig = new Class[elements.size()];
|
final Class<?>[] sig = new Class[elements.size()];
|
||||||
for (int i = 0; i < elements.size(); i++) {
|
for (int i = 0; i < elements.size(); i++) {
|
||||||
sig[i] = elements.get(i).getJavaType();
|
sig[i] = resolveElementJavaType( elements.get( i ) );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
constructor = type.getDeclaredConstructor( sig );
|
constructor = type.getDeclaredConstructor( sig );
|
||||||
|
@ -40,6 +43,17 @@ public class RowTransformerConstructorImpl<T> implements RowTransformer<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Class<?> resolveElementJavaType(TupleElement<?> element) {
|
||||||
|
if ( element instanceof SqmExpressibleAccessor ) {
|
||||||
|
SqmExpressible expressible = ( (SqmExpressibleAccessor) element ).getExpressible();
|
||||||
|
if ( expressible != null ) {
|
||||||
|
return expressible.getExpressibleJavaType().getJavaTypeClass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return element.getJavaType();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T transformRow(Object[] row) {
|
public T transformRow(Object[] row) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue