title: add foreign key attribute in the owner class?
body: <p>I have this simple entity class in a spring boot app:</p>
  <pre><code>@Entity
  public class Plant {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(nullable = false, updatable = false)
      private Long id;
      private String code;
      private String location;
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name=&quot;companyid&quot;, nullable = false)
      private Company company;
  }
  </code></pre>
  <p>This represents a plant. A company can have one or more plants and one plant can belong just to one company. In the postgresql db the <code>plant</code> table was created with a <code>companyid</code> foreign key field referrencing to the <code>id</code> field of the <code>company</code> table. Fine.</p>
  <p>Now, my question is: do I have to add the <code>companyid</code> attribute to the <code>plant</code> class? If yes, with <code>transient</code> annotation? Because the field is already in the database because of the <code>company</code> relationship.</p>
  <p>Later if I will send a post request to this backend f. e. to create a new plant, I can send a whole <code>company</code> object, but just only the <code>companyid</code> too.</p>
  <p>What is the right way to model this? What is the standard? I remember, in EF core if I have referrenced a navigation property I added the according <code>id</code> attribute (aka foreign key) to the model class too.</p>