title: How can i display values from 2 entites in one form using thymeleaf
body: <p>I am using Spring Boot, Thymeleaf, Hibernate, and JPA to develop this application. I have mapped a relationship between the two entities I need to retrieve data from and am wondering how to display data from the two tables on the page </p>
  
  <p>Can someone tell me how can I display values from 2 entities in one form using Thymeleaf? I can't find any tutorial, thanks in advance </p>
  
  <pre class="lang-java prettyprint-override"><code>@Getter
  @Setter
  @NoArgsConstructor
  
  @Entity
  @Table(name = "users")
  public class User {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      private String name;
  
      @OneToOne(cascade = CascadeType.ALL)
      private UserDetails userDetails;
  
      public User(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>@Data
  @NoArgsConstructor
  
  @Entity
  @Table(name = "user_details")
  public class UserDetails {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      private String email;
  
      public UserDetails(String email) {
          this.email = email;
      }
  }
  </code></pre>