Stackoverflowerror occurs even after using jsonProperties. How to solve it?

Viewed 31

A.class

  @Getter
  @Entity
  @Table(name = "A")
  public class A extends JpaEntity<Long> {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "aId", nullable = false)
      private Long id;

      @OneToMany(fetch = FetchType.EAGER)
      @JoinColumn(name = "aId")
      @Setter
      private Set<relationship_table_between_a_and_b> bOfa;
}

relationship_table_between_a_and_b.class

   @Entity
   @Table(name = "relationship_table_between_a_and_b")
   @Getter
   public static relationship_table_between_a_and_b extends JpaEntity<relationship_table_between_a_and_b.Id> {
       @EmbeddedId
       @Setter
       private Id id;
  
       @Embeddable
       @Getter
       public static class Id implements Serializable {
           @Setter
           @Column(name="aId", nullable = false)
           private Long aId;

           @Setter
           @OneToOne(fetch = FetchType.EAGER, optional = false)
           @JoinColumn(name="bId", nullable = false)
           private B b;
      }
   }

B.class

   public static B extends JpaEntity<Long> {
       @Id
       @GeneratedValue(strategy = GenerationType.IDENTITY)
       @Column(name = "bId", nullable = false)
       private Long id;

       @OneToMany(fetch = FetchType.EAGER)
       @JoinTable(
           name = "relationship_table_between_b_and_a",
           joinColumns = @JoinColumn(name = "bId", nullable = false),
           inverseJoinColumns = @JoinColumn(name = "aId", nullable = false))
       @Setter
       @JsonIgnoreProperties("bOfa")
       private List<A> as;
   }

I tried several ways but didn't solve the stackoverflowerror Could not solve the infinite reference that occurs when as of class B refers to bToa of a again. I want to solve this problem... please help

0 Answers
Related