Lombok.hashCode issue with "java.lang.StackOverflowError: null"
<p>I have two tables has one to one relationship as below:</p>

<pre><code>@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Book {
  @Id
  @GeneratedValue(strategy = GenerationType.TABLE)
  private int id;

  private String name;

  @OneToOne(cascade = CascadeType.ALL)
  @JoinColumn(name = "book_dtail_id")
  private BookDetail bookDetail;
}

@Entity
@Table(name = "book_detail")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BookDetail {
  @Id
  @GeneratedValue(strategy = GenerationType.TABLE)
  private Integer id;

  @Column(name = "number_of_pages")
  private Integer numberOfPages;

  @OneToOne(mappedBy = "bookDetail")
  private Book book;
}
</code></pre>

<p>I used a Form to input data as below</p>

<pre><code>@Data
@NoArgsConstructor
@AllArgsConstructor
public class BookForm {
  Book book;
  BookDetail bookDetail;
}
</code></pre>

<p>The controller looks like this:</p>

<pre><code>String handleNewBook(Model model){
  Book book = new Book();
  BookDetail bookDetail = new BookDetail();
  BookForm bookForm = new BookForm(book, bookDetail);

  model.addAttribute("bookForm", bookForm);
  return "index";
}

String handleSaveBookCreate(BookForm bookForm, Model model){
    bookForm.getBook().setBookDetail(bookForm.getBookDetail());
    bookForm.getBookDetail().setBook(bookForm.getBook());
    bookService.save(bookForm.getBook()));
    return "index";
}
</code></pre>

<p>Last is my form as below:</p>

<pre><code>&lt;form role="form" action="#" th:object="${bookForm}" th:action="@{/book}" method="POST"&gt;
    &lt;input type="text" th:field="*{book.name}"/&gt;
    &lt;input type="text" th:filed="*{bookDetail} == null ? '' : *{bookDetail.numberOfPages}"  placeholder="Enter Book Page Numbers"/&gt;
    &lt;button type="submit"&gt;Submit&lt;/button&gt;
&lt;/form&gt;
</code></pre>

<p>everything seems no problems, but when I "bookService.save(bookForm.getBook()));" is executed, I got error as below</p>

<pre><code>java.lang.StackOverflowError: null, 
at com.zangland.study.jpa.entity.BookDetail.hashCode(BookDetail.java:17) ~[classes/:na]
at com.zangland.study.jpa.entity.Book.hashCode(Book.java:16) ~[classes/:na]
at com.zangland.study.jpa.entity.BookDetail.hashCode(BookDetail.java:17) ~[classes/:na]
at com.zangland.study.jpa.entity.Book.hashCode(Book.java:16) ~[classes/:na]
</code></pre>

<p>repeat the same as above about 100 lines.... do this mean that I can't use Lombok.hashCode? </p>

<p>Saved Book:  '32768','Spring JPA','32768'
Saved BookDetail: '32768','1157'</p>