title: JPA one to one mapping creates multiple query when child entity is not found
body: <p>I have a parent entity 'contracts' that has a one-to-one relation with another entity 'child-contract'. the interesting thing is that the mapping field ('contract_number')id not a primary key-foreign key but is rather a unique field in both the tables. Also it is possible for a contracts to not have any child contract altogether. With this configuration I have observed hibernate to generate 1 additional query every time a contracts does not have a child-contract. I filed this behavior very strange. Is there a way to stop these unnecessary query generation or have I got something wrong.</p>
  <p>below is a piece of my code configuration.</p>
  <pre><code>@Data
  @Entity
  @Table(name = &quot;contracts&quot;)
  public class Contracts implements Serializable {
  
      @Id
      @JsonIgnore
      @Column(name = &quot;id&quot;)
      private String id;
  
    @JsonProperty(&quot;contract_number&quot;)
    @Column(name = &quot;contract_number&quot;)
    private String contractNumber;
  
  
      @OneToOne(fetch=FetchType.EAGER)
      @Fetch(FetchMode.JOIN)
      @JsonProperty(&quot;crm_contracts&quot;)
      @JoinColumn(name = &quot;contract_number&quot;, referencedColumnName = &quot;contract_number&quot;)
      private ChildContract childContract ;
  }
  
  @Data
  @NoArgsConstructor
  @Entity
  @Table(name = &quot;child_contract&quot;)
  @BatchSize(size=1000)
  public class ChildContract implements Serializable {
  
    private static final long serialVersionUID = 1L;
  
    @Id
    @JsonProperty(&quot;id&quot;)
    @Column(name = &quot;id&quot;)
    private String id;
  
    @JsonProperty(&quot;contract_number&quot;)
    @Column(name = &quot;contract_number&quot;)
    private String contractNumber;
  
  }
  </code></pre>
  <p>Please help.</p>
  <p>Thank-you</p>