title: JPA mapping OneToOne by Entity or By Id
body: <p>What is the reason of following mapping?</p>
  <pre><code>  @Column(name = &quot;inspection_platform_id&quot;)
    private Long inspectionPlatformEntityId;
  
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = &quot;inspection_platform_id&quot;, insertable = false, updatable = false)
    private InspectionPlatformEntity inspectionPlatformEntity;
  </code></pre>
  <p>Why do we need to specify mapping for foreign key if we specified mapping for whole entity and we can easily extract ID from that entity.</p>
  <p>I have a suggestion that this is due to lazy loading so we do not need to fetch the whole entity just to extract it's ID, but I also seen this approach with EAGER fetch type so I don't understand the reason</p>