title: How to map two tables like primary key and foreign key in JPA Springboot?
body: <p>I have these two tables and want to map the userName fields so that I can query messages of a specific user only. How can I do this ?</p>
  <pre><code>@Entity
  public class User {
      
      
      @Id
      private String userName;
  }
  
  
  @Entity(name = &quot;message&quot;)
  public class Message {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private UUID messageID;
      String message;
      String userName;
      Long timeStamp;
      boolean isSent;
  
  }
      
  </code></pre>
  <p>The mapping should be done between userName.</p>