title: Hibernate - One to Many relationship - only id
body: <p>I have two classes and relation between is OneToMany. Its working ok, but i would like to save only ID of the user.</p>
  
  <p>Data Class:</p>
  
  <pre><code>public class Data {
  
  @Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE)
  private Long id;
  
  @NotEmpty
  private String phoneName;
  
  @NotEmpty
  private String phoneId;
  
  @NotEmpty
  private String phoneNumber;
  
  @ManyToOne
  @JoinColumn(name="user_id")
  private User userId;
  </code></pre>
  
  <p>and User Class:</p>
  
  <pre><code>@Entity
  public class User {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private int userId;
  
  @NotEmpty
  private String userEmail;
  
  @NotEmpty
  private String password;
  </code></pre>
  
  <p>When I do query I get also all data of the user:</p>
  
  <pre><code>[
   {
    "id": 10,
    "phoneName": "SOME CRAZY NAME",
    "phoneId": "165464646464",
    "phoneNumber": "040435005",
    "userId": {
     "userEmail": "xxx@gmail.com",
     "password": "secret",
     "id": 3
    }
   }
  ]
  </code></pre>
  
  <p>But I would like to get only id of the user, without email and password. Is there any other way to annotate @OneToMany to achieve this? </p>