fix bug in checking of PageRequest type arg
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
8aaf0c7c9d
commit
ccbb84a6c4
|
@ -1409,18 +1409,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
}
|
||||
else {
|
||||
multivalued.add( false );
|
||||
final Types types = context.getTypeUtils();
|
||||
final TypeMirror parameterType = parameterType( parameter );
|
||||
boolean pageRequest = typeNameEquals( parameterType, JD_PAGE_REQUEST );
|
||||
if ( isOrderParam( typeName(parameterType) ) || pageRequest ) {
|
||||
final TypeMirror typeArgument = getTypeArgument( parameterType );
|
||||
if ( typeArgument == null ) {
|
||||
missingTypeArgError( entity.getSimpleName().toString(), parameter, pageRequest );
|
||||
}
|
||||
else if ( !types.isSameType( typeArgument, entity.asType() ) ) {
|
||||
wrongTypeArgError( entity.getSimpleName().toString(), parameter, pageRequest );
|
||||
}
|
||||
}
|
||||
checkFinderParameter(entity, parameter);
|
||||
}
|
||||
}
|
||||
putMember( methodKey,
|
||||
|
@ -1445,6 +1434,21 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
);
|
||||
}
|
||||
|
||||
private void checkFinderParameter(TypeElement entity, VariableElement parameter) {
|
||||
final Types types = context.getTypeUtils();
|
||||
final TypeMirror parameterType = parameterType(parameter);
|
||||
boolean pageRequest = typeNameEquals( parameterType, JD_PAGE_REQUEST );
|
||||
if ( isOrderParam( typeName(parameterType) ) || pageRequest ) {
|
||||
final TypeMirror typeArgument = getTypeArgument( parameterType );
|
||||
if ( typeArgument == null ) {
|
||||
missingTypeArgError( entity.getSimpleName().toString(), parameter, pageRequest );
|
||||
}
|
||||
else if ( !types.isSameType( typeArgument, entity.asType() ) ) {
|
||||
wrongTypeArgError( entity.getSimpleName().toString(), parameter, pageRequest );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createCriteriaDelete(ExecutableElement method, TypeMirror returnType) {
|
||||
final TypeElement entity = primaryEntity;
|
||||
if ( entity == null) {
|
||||
|
@ -2689,22 +2693,26 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
}
|
||||
}
|
||||
if ( returnType != null ) {
|
||||
final Types types = context.getTypeUtils();
|
||||
for ( VariableElement parameter : method.getParameters() ) {
|
||||
final TypeMirror parameterType = parameterType( parameter );
|
||||
final TypeMirror typeArgument = getTypeArgument( parameterType );
|
||||
final boolean pageRequest = typeNameEquals(parameterType, JD_PAGE_REQUEST);
|
||||
if ( isOrderParam( typeName(parameterType) ) || pageRequest ) {
|
||||
if ( typeArgument == null ) {
|
||||
missingTypeArgError( returnType.toString(), parameter, pageRequest );
|
||||
final TypeElement entity = implicitEntityType(returnType);
|
||||
if ( entity != null ) {
|
||||
checkFinderParameter(entity, parameter);
|
||||
}
|
||||
else if ( !types.isSameType(typeArgument, returnType) ) {
|
||||
wrongTypeArgError( returnType.toString(), parameter, pageRequest );
|
||||
// else? what?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable TypeElement implicitEntityType(@Nullable TypeMirror resultType) {
|
||||
if ( resultType != null && resultType.getKind() == TypeKind.DECLARED) {
|
||||
final DeclaredType declaredType = (DeclaredType) resultType;
|
||||
final Element typeElement = declaredType.asElement();
|
||||
if ( hasAnnotation(typeElement, ENTITY) ) {
|
||||
return (TypeElement) typeElement;
|
||||
}
|
||||
}
|
||||
return primaryEntity;
|
||||
}
|
||||
|
||||
private boolean typeNameEquals(TypeMirror parameterType, String typeName) {
|
||||
if ( parameterType.getKind() == TypeKind.DECLARED ) {
|
||||
|
|
Loading…
Reference in New Issue