jpa onetoone fetch join 依然出现N+1条sql

之前配置

   @Id

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "DOH_ID", unique = true, nullable = false, updatable = false)
    @JsonBackReference
    public DoDeliveryOrderHeader getDoDeliveryOrderHeader() {
        return this.doDeliveryOrderHeader;
    }

    public void setDoDeliveryOrderHeader(DoDeliveryOrderHeader doDeliveryOrderHeader) {
        this.doDeliveryOrderHeader = doDeliveryOrderHeader;
    }

 

修改后配置 加粗部分是新加的

    @Id
    @Column(name = "DOH_ID")
    public Integer getDohId() {
        return this.doDeliveryOrderHeader.getDohId();
    }

    public void setDohId(Integer dohId) {
        this.dohId = dohId;
    }

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "DOH_ID", unique = true, nullable = false, updatable = false)
    @JsonBackReference
    public DoDeliveryOrderHeader getDoDeliveryOrderHeader() {
        return this.doDeliveryOrderHeader;
    }

    public void setDoDeliveryOrderHeader(DoDeliveryOrderHeader doDeliveryOrderHeader) {
        this.doDeliveryOrderHeader = doDeliveryOrderHeader;
    }

你可能感兴趣的:(jpa onetoone fetch join 依然出现N+1条sql)