HHH-17729 move validation of constructors in HQL instantiations to SemanticQueryBuilder
also validate injection via fields/properties
This commit is contained in:
parent
dcb2c60d4e
commit
a9ea331e40
|
@ -143,7 +143,7 @@ public class SqmDynamicInstantiation<T>
|
||||||
|
|
||||||
private List<Class<?>> argumentTypes() {
|
private List<Class<?>> argumentTypes() {
|
||||||
return getArguments().stream()
|
return getArguments().stream()
|
||||||
.map(arg -> arg.getNodeJavaType().getJavaTypeClass())
|
.map(arg -> arg.getNodeJavaType() == null ? Void.class : arg.getNodeJavaType().getJavaTypeClass())
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,11 +74,11 @@ public class InstantiationHelper {
|
||||||
for (int i = 0; i < argumentTypes.size(); i++ ) {
|
for (int i = 0; i < argumentTypes.size(); i++ ) {
|
||||||
final Type parameterType = genericParameterTypes[i];
|
final Type parameterType = genericParameterTypes[i];
|
||||||
final Class<?> argumentType = argumentTypes.get( i );
|
final Class<?> argumentType = argumentTypes.get( i );
|
||||||
final Class<?> argType = parameterType instanceof Class<?>
|
final Class<?> type = parameterType instanceof Class<?>
|
||||||
? (Class<?>) parameterType
|
? (Class<?>) parameterType
|
||||||
: typeConfiguration.getJavaTypeRegistry().resolveDescriptor( parameterType ).getJavaTypeClass();
|
: typeConfiguration.getJavaTypeRegistry().resolveDescriptor( parameterType ).getJavaTypeClass();
|
||||||
|
|
||||||
if ( !areAssignmentCompatible( argType, argumentType ) ) {
|
if ( !areAssignmentCompatible( type, argumentType ) ) {
|
||||||
if ( log.isDebugEnabled() ) {
|
if ( log.isDebugEnabled() ) {
|
||||||
log.debugf(
|
log.debugf(
|
||||||
"Skipping constructor for dynamic-instantiation match due to argument mismatch [%s] : %s -> %s",
|
"Skipping constructor for dynamic-instantiation match due to argument mismatch [%s] : %s -> %s",
|
||||||
|
|
Loading…
Reference in New Issue