mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 12:14:47 +00:00
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 @@ private void validateBidirectionalMapping(
|
||||
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 @@ private void validateBidirectionalMapping(
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user