Hibernate OneToMany java.lang.StackOverflowError

I had a very similar issue. I was using Lombok’s @Data annotation on my model objects to auto-generate getters, setters, and other standard methods. I believe the toString() method generated by Lombok introduced a circular dependency between my Team and League objects. When I tried to get the Set<teams> teams from my League object, I got a java.lang.StackOverflowError because Spring was calling the toString method for logging purposes.

I resolved this by getting rid of Lombok’s toString() method. I replaced the @Data annotation with Lombok’s @Getter and @Setter annotations. That way I still could benefit from free getters and setters without getting the toString() method.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)