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.util.List;
|
||||
|
||||
import org.hibernate.query.sqm.SqmExpressible;
|
||||
import org.hibernate.query.sqm.tree.SqmExpressibleAccessor;
|
||||
|
||||
/**
|
||||
* {@link RowTransformer} instantiating an arbitrary class
|
||||
*
|
||||
|
@ -28,7 +31,7 @@ public class RowTransformerConstructorImpl<T> implements RowTransformer<T> {
|
|||
final List<TupleElement<?>> elements = tupleMetadata.getList();
|
||||
final Class<?>[] sig = new Class[elements.size()];
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
sig[i] = elements.get(i).getJavaType();
|
||||
sig[i] = resolveElementJavaType( elements.get( i ) );
|
||||
}
|
||||
try {
|
||||
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
|
||||
public T transformRow(Object[] row) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue