当前位置: 代码迷 >> SQL >> jpa onetoone fetch join 仍然出现N+1条sql
  详细解决方案

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

热度:299   发布时间:2016-05-05 09:57:01.0
jpa onetoone fetch join 依然出现N+1条sql

之前配置

[email protected]

??? @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
?? [email protected](name = "DOH_ID")
?? ?public Integer getDohId() {
?? ???? return this.doDeliveryOrderHeader.getDohId();
?? ?}

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

?? [email protected](fetch = FetchType.LAZY)
?? [email protected](name = "DOH_ID", unique = true, nullable = false, updatable = false)
?? [email protected]
?? ?public DoDeliveryOrderHeader getDoDeliveryOrderHeader() {
?? ???? return this.doDeliveryOrderHeader;
?? ?}

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

  相关解决方案