* Non-owning mappings that need to look up the owning mapping, should call
* this method with their respective accessor to check for circular mappedBy
* references. If the referencingAccessor is null, no check will be made.
*/
public DatabaseMapping getMappingForAttributeName(String attributeName, MetadataAccessor referencingAccessor) {
MetadataAccessor accessor = (MetadataAccessor) getAccessorFor(attributeName);
if (accessor != null) {
// If the accessor is a relationship accessor than it may or may
// not have been processed yet. Fast track its processing if it
// needs to be. The process call will do nothing if it has already
// been processed.
if (accessor.isRelationship()) {
RelationshipAccessor relationshipAccessor = (RelationshipAccessor) accessor;
// Check that we don't have circular mappedBy values which
// will cause an infinite loop.
if (referencingAccessor != null && ! relationshipAccessor.isManyToOne() && relationshipAccessor.getMappedBy().equals(referencingAccessor.getAttributeName())) {