title: Spring boot JPA fetch specific column from crudRepository query
body: <p>Im trying to get the "name" field from my user class within my Employee class so i can avoid making an additional query to get the user name.</p>
  
  <p>For the moment, I've only been able to get the user_id this way</p>
  
  <p>My user class</p>
  
  <pre><code>@Entity @Table(name="user", schema = "public") @Getter @Setter @NoArgsConstructor @Accessors(chain = true)
  public class User implements Serializable{
      private @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name = "user_id") Long id;
      private @Column(unique = true) String email;
      private String name;
  }
  </code></pre>
  
  <p>My Employee class</p>
  
  <pre><code>@Entity @Table(name = "employee",schema = "public") @Getter @Setter @NoArgsConstructor @Accessors(chain = true)
  public class Employee implements Serializable {
      private @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name = "employee_id") Long id;
      @JsonIgnore @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "fk_user_id",insertable = false,updatable = false) private User user;
      private @Column(name="fk_user_id") Long userId;
  }
  </code></pre>
  
  <p>i know i can not retrieve the name without selecting it so i tried using a custom query on my crudRepository </p>
  
  <pre><code>public interface EmployeeRepository extends CrudRepository&lt;Employee, Long&gt;{
      @Query(value = "SELECT employee.*, public.user.name FROM public.employee INNER JOIN public.user ON public.user.user_id = employee.fk_user_id ", nativeQuery = true)
      List&lt;Employee&gt; findEmployees();
  }
  </code></pre>
  
  <p>The query returns what i expect but i dont know how to fetch the resulted column "name"on my Employee class</p>
  
  <p>Any help or guidance is welcome, thanks for reading</p>