hibernate java.lang.StackOverflowError: null

An error is reported when using hibernate

java.lang.StackOverflowError: null

The stack of the current thread is full

 

java.lang.StackOverflowError: null
    at java.util.AbstractCollection.toString(AbstractCollection.java:454) ~[?:1.8.0_111]
    at org.hibernate.collection.internal.PersistentBag.toString(PersistentBag.java:538) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at java.lang.String.valueOf(String.java:2994) ~[?:1.8.0_111]
    at java.lang.StringBuilder.append(StringBuilder.java:131) ~[?:1.8.0_111]
    at com.crhms.seabow.model.User.toString(User.java:12) ~[classes/:?]
    at java.lang.String.valueOf(String.java:2994) ~[?:1.8.0_111]
    at java.lang.StringBuilder.append(StringBuilder.java:131) ~[?:1.8.0_111]
    at com.crhms.seabow.model.Role.toString(Role.java:12) ~[classes/:?]
    at java.lang.String.valueOf(String.java:2994) ~[?:1.8.0_111]
    at java.lang.StringBuilder.append(StringBuilder.java:131) ~[?:1.8.0_111]
    at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[?:1.8.0_111]
    at org.hibernate.collection.internal.PersistentBag.toString(PersistentBag.java:538) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
    at java.lang.String.valueOf(String.java:2994) ~[?:1.8.0_111]
    at java.lang.StringBuilder.append(StringBuilder.java:131) ~[?:1.8.0_111]
    at com.crhms.seabow.model.User.toString(User.java:12) ~[classes/:?]
    at java.lang.String.valueOf(String.java:2994) ~[?:1.8.0_111]
    at java.lang.StringBuilder.append(StringBuilder.java:131) ~[?:1.8.0_111]
    at com.crhms.seabow.model.Role.toString(Role.java:12) ~[classes/:?]
    at java.lang.String.valueOf(String.java:2994) ~[?:1.8.0_111]

 

After checking the reason, it should appear on the toString method of the entity. If there is an associated attribute (1 to many, etc.), it cannot be added to the toString method. Otherwise, if it appears, you print me, I print you, and keep typing

Although the toString method is not written in my code, our Lombok data annotation , which comes with toString, can only rewrite the toString method and overwrite the toString method of Lombok

Problem solving

Similar Posts: