hack in acceptance of PageRequest<?>

JD examples and TCK require this, though it's not really correct

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-03-28 01:52:03 +01:00
parent ccbb84a6c4
commit bab8b98a59
1 changed files with 7 additions and 5 deletions

View File

@ -1439,7 +1439,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
final TypeMirror parameterType = parameterType(parameter); final TypeMirror parameterType = parameterType(parameter);
boolean pageRequest = typeNameEquals( parameterType, JD_PAGE_REQUEST ); boolean pageRequest = typeNameEquals( parameterType, JD_PAGE_REQUEST );
if ( isOrderParam( typeName(parameterType) ) || pageRequest ) { if ( isOrderParam( typeName(parameterType) ) || pageRequest ) {
final TypeMirror typeArgument = getTypeArgument( parameterType ); final TypeMirror typeArgument = getTypeArgument( parameterType, entity );
if ( typeArgument == null ) { if ( typeArgument == null ) {
missingTypeArgError( entity.getSimpleName().toString(), parameter, pageRequest ); missingTypeArgError( entity.getSimpleName().toString(), parameter, pageRequest );
} }
@ -1552,17 +1552,17 @@ public class AnnotationMetaEntity extends AnnotationMeta {
return new OrderBy( path, descending, ignoreCase ); return new OrderBy( path, descending, ignoreCase );
} }
private static @Nullable TypeMirror getTypeArgument(TypeMirror parameterType) { private static @Nullable TypeMirror getTypeArgument(TypeMirror parameterType, TypeElement entity) {
switch ( parameterType.getKind() ) { switch ( parameterType.getKind() ) {
case ARRAY: case ARRAY:
final ArrayType arrayType = (ArrayType) parameterType; final ArrayType arrayType = (ArrayType) parameterType;
return getTypeArgument( arrayType.getComponentType() ); return getTypeArgument( arrayType.getComponentType(), entity);
case DECLARED: case DECLARED:
final DeclaredType type = (DeclaredType) parameterType; final DeclaredType type = (DeclaredType) parameterType;
switch ( typeName(parameterType) ) { switch ( typeName(parameterType) ) {
case LIST: case LIST:
for (TypeMirror arg : type.getTypeArguments()) { for (TypeMirror arg : type.getTypeArguments()) {
return getTypeArgument( arg ); return getTypeArgument( arg, entity);
} }
return null; return null;
case HIB_ORDER: case HIB_ORDER:
@ -1572,7 +1572,9 @@ public class AnnotationMetaEntity extends AnnotationMeta {
for ( TypeMirror arg : type.getTypeArguments() ) { for ( TypeMirror arg : type.getTypeArguments() ) {
switch ( arg.getKind() ) { switch ( arg.getKind() ) {
case WILDCARD: case WILDCARD:
return ((WildcardType) arg).getSuperBound(); final TypeMirror superBound = ((WildcardType) arg).getSuperBound();
// horrible hack b/c Jakarta Data is not typesafe
return superBound == null ? entity.asType() : superBound;
case ARRAY: case ARRAY:
case DECLARED: case DECLARED:
case TYPEVAR: case TYPEVAR: