HHH-18179 incorrect warning issued for mappedBy with property access
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
08d0d78147
commit
9ac37a19c0
|
@ -1005,7 +1005,8 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
final AnnotationValue annotationVal =
|
||||
castNonNull(getAnnotationValue(annotation, "mappedBy"));
|
||||
for ( Element member : context.getAllMembers(assocTypeElement) ) {
|
||||
if ( propertyName(this, member).contentEquals(mappedBy) ) {
|
||||
if ( propertyName(this, member).contentEquals(mappedBy)
|
||||
&& compatibleAccess(assocTypeElement, member) ) {
|
||||
validateBackRef(memberOfClass, annotation, assocTypeElement, member, annotationVal);
|
||||
return;
|
||||
}
|
||||
|
@ -1018,6 +1019,19 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean compatibleAccess(TypeElement assocTypeElement, Element member) {
|
||||
final AccessType memberAccessType = determineAnnotationSpecifiedAccessType( member );
|
||||
final AccessType accessType = memberAccessType == null ? getAccessType(assocTypeElement) : memberAccessType;
|
||||
switch ( member.getKind() ) {
|
||||
case FIELD:
|
||||
return accessType == AccessType.FIELD;
|
||||
case METHOD:
|
||||
return accessType == AccessType.PROPERTY;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void validateBackRef(
|
||||
Element memberOfClass,
|
||||
AnnotationMirror annotation,
|
||||
|
@ -2106,7 +2120,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
|
||||
private AccessType getAccessType(TypeElement entity) {
|
||||
final String entityClassName = entity.getQualifiedName().toString();
|
||||
determineAccessTypeForHierarchy(entity, context );
|
||||
determineAccessTypeForHierarchy( entity, context );
|
||||
return castNonNull( context.getAccessTypeInfo( entityClassName ) ).getAccessType();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue