title: How to retrieve ONE column from another table with Foreign key using Hibernate / JPA
body: <p>I would like to use the Foreign key &quot;<code>MODEL_ID</code>&quot; to retrieve just one column &quot;<code>MODEL_NAME</code>&quot; from the TT_CARS table,
  I tried the following code, that works but it returns the whole CARS object.</p>
  <pre><code>@JoinColumn(name = &quot;MODEL_ID&quot;, referencedColumnName = &quot;ID&quot;)
  @ManyToOne(fetch = FetchType.EAGER)
  private CARS cars;
  </code></pre>
  <p>Also I tried the code below, its also not working</p>
  <pre><code>@SecondaryTable(name = &quot;TT_CARS&quot;, pkJoinColumns = @PrimaryKeyJoinColumn(name = &quot;ID&quot;, referencedColumnName=&quot;MODEL_ID&quot;))
  </code></pre>
  <p>Is there other way to retieve just the column (<code>MODEL_NAME</code>) using hibernate and JPA??</p>
  <p>remarks: The modelName should be part of the <code>Options</code> class.</p>
  <p>my code</p>
  <pre><code>import javax.persistence.*;
  import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Size;
  
  @Entity
  @Table(name = &quot;TT_OPTIONS&quot;)
  public class Options  {
  
      @Id
      @Column(name = &quot;ID&quot;)
      private String id;
  
      @NotNull
      @Column(name = &quot;DESCRIPTION&quot;, nullable = false)
      private String description;
  
      @Column(name = &quot;MODEL_ID&quot;) // Foreign key
      private Long modelId;
  
      @Column(name = &quot;MODEL_NAME&quot;, table = &quot;TT_CARS&quot;) // this is the column name I would like to retrieve from the TT_CARS table
      private String modelName;
  
      // getters and setters
  }
  </code></pre>