I’m having the exact same issue. The versions we are using are: Hibernate: v5.4.6.Final Spring Boot: v2.2.0.RELEASE Spring: v5.2.0.RELEASE Our mapping is as follows (changed classnames to prevent production data from leaking out): Student.java @OneToMany (mappedBy = "bookPrimaryKey.student", cascade = CascadeType.ALL, orphanRemoval = true) private Set<Book> books = new HashSet<>(); Book.java @EmbeddedId private BookPrimaryKey bookPrimaryKey = new BookPrimaryKey(); BookPrimaryKey.java (has @Embeddable. Next to the student field this primary key class also has 2 other fields that are used as composite ID, one of those fields is a custom value type for dates which can not be used in @Idclass because of serialization issues) @ManyToOne (fetch = FetchType.LAZY) @JoinColumn (name = "student_id", nullable = false, insertable = false, updatable = false) private Student student; The problem is that the book tries to load the student, and the student tries to load the list of books (even though FetchType.LAZY is on there), introducing an infinite loop. An interesting observation we made is that whenever we delete the target directory (we use QueryDSL to generate JPA queries), then run mvn clean process-resources, the issue does not occur. However, as soon as we add mvn package to the pipeline, the Stackoverflow error as described by OP occurs. Same story for mvn clean install. So it looks like somewhere in the package step something happens that introduces this issue. |