public Attribute getInversedBy ( ) { // FIXME besides checking mappedBy attr name also check // attr.getRefEntity().getFullyQualifiedName if ( hasRefEntity ( ) ) { return Streams . stream ( getRefEntity ( ) . getAtomicAttributes ( ) ) . filter ( Attribute :: isMappedBy ) . filter ( attr -> getName ( ) . equals ( attr . getMappedBy ( ) . getName ( ) ) ) . findFirst ( ) . orElse ( null ) ; } else { return null ; } }
For a reference type attribute searches the referenced entity for its inversed attribute . This is the one - to - many attribute that has mappedBy set to this attribute . Returns null if this is not a reference type attribute or no inverse attribute exists .