package org.odindelrio.dddaopentitybehaviour.domain;

import org.odindelrio.dddaopentitybehaviour.domain.exception.FollowerCantFollowHimSelfException;

public class Follower {
  private final String followerId;
  public FollowersRepository followersRepository;

  public Follower(String followerId) {
    this.followerId = followerId;
  }

  public String getFollowerId() {
    return followerId;
  }

  public void follow(Followable followable) {
    if (followable.getFollowableId().equals(followerId)) {
      throw new FollowerCantFollowHimSelfException();
    }

    System.out.println("INSIDE Follower.follow() method");

    this.followersRepository.persistFollower(this, followable);
  }
}

package org.odindelrio.dddaopentitybehaviour.domain;

import org.odindelrio.dddaopentitybehaviour.domain.exception.FollowerCantFollowHimSelfException;

public class Follower {
  private final String followerId;
  public transient FollowersRepository followersRepository;

  public Follower(String followerId) {
    this.followerId = followerId;
  }

  public String getFollowerId() {
    return followerId;
  }

  public void follow(Followable followable) {
    if (followable.getFollowableId().equals(followerId)) {
      throw new FollowerCantFollowHimSelfException();
    }

    System.out.println("INSIDE Follower.follow() method");

    this.followersRepository.persistFollower(this, followable);
  }
}

Make entity dependency transient, telling serializers that repository shouldn't be serialized.
Make entity dependency transient, telling serializers that repository shouldn't be serialized.
