code: public void updateMappedByEntities(
        @Nonnull Entity entity, @Nullable @CheckForNull Entity existingEntity) {
      entity
          .getEntityType()
          .getMappedByAttributes()
          .forEach(
              mappedByAttr -> {
                AttributeType type = mappedByAttr.getDataType();
                if (type != ONE_TO_MANY) {
                  throw new RuntimeException(
                      format(
                          "Attribute [%s] of type [%s] can't be mapped by another attribute",
                          mappedByAttr.getName(), type.toString()));
                }
                updateMappedByEntitiesOneToMany(entity, existingEntity, mappedByAttr);
              });
    }
docs: For entities with attributes that are part of a bidirectional relationship update the other
  side of the relationship.
  
  @param entity created or updated entity
  @param existingEntity existing entity