Spring boot Spring data pageable left join fetch在后台执行多个查询

Spring boot Spring data pageable left join fetch在后台执行多个查询,spring-boot,spring-data-jpa,jpql,Spring Boot,Spring Data Jpa,Jpql,我对实体的定义如下 @Entity @Table(name = "ORDER") public class Order{ @Id @Column(name = "ID") private String id; @NotFound(action= NotFoundAction.IGNORE) @ManyToOne(fetch = FetchType.LAZY)

我对实体的定义如下

@Entity
@Table(name = "ORDER")
public class Order{


        @Id
        @Column(name = "ID")
        private String id;

         @NotFound(action= NotFoundAction.IGNORE)
        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "CUSTOMER_FK")
        private Customer customer;

       @ManyToOne(fetch = FetchType.EAGER)
        @JoinColumn(name = "DEALER_FK")
        private Dealer dealer;
}
我的存储库是

@Repository
public interface OrderRepository extends PagingAndSortingRepository<Order, String> {

  @Query(value = "  Select ord from Order ord " +
            "   LEFT JOIN FETCH  ord.customer cust" +
            "  where ord.dealer.id = :idDealer ",
            countQuery = "  Select count(ord) from Order ord " +
            "  where ord.dealer.id = :idDealer ")
    Page<PosWorkOrderLine> findByDealerIdWithPagination(@Param("idDealer") String dealerId, Pageable pageable);
我不希望对客户进行单独的查询,但仍然可以看到每个记录的客户查询。 我尝试了快速抓取(FetchType.eager)和FetchType以及@Fetch(FetchMode.JOIN),但还是一样吗

如果我缺少一些配置或映射,我会寻找在一个查询中执行的所有连接,而不是针对每个行顺序执行单独的查询

这是我在堆栈溢出中的第一个问题,如果有任何错误,请道歉

13:58:15.152 [http-nio-8080-exec-2] DEBUG o.h.SQL - select TOP(?) ord0_.ID as ORD1_89_0_, custome1_.CUSTOMER_PK as CUSTOMER1_30_1_,  ord0_.DEALER_FK as DEALER105_89_0_, from work_order_line posworkord0_ left outer join customer custome1_ on ord0_.CUSTOMER_FK=custome1_.CUSTOMER_PK where ord0_.DEALER_FK=?
13:58:15.343 [http-nio-8080-exec-2] DEBUG o.h.SQL - select custome0_.CUSTOMER_PK as CUSTOMER1_30_0_, custome0_.NAME as NAME2_30_0_ where customer custome0_ where custome0_.CUSTOMER_PK=?
13:58:15.387 [http-nio-8080-exec-2] DEBUG o.h.SQL - select dealers0_.DEALER_PK as DEALER_S1_34_0_ from dealer dealers0_ where dealers0_.DEALER_PK=?
13:58:15.439 [http-nio-8080-exec-2] DEBUG o.h.SQL - select custome0_.CUSTOMER_PK as CUSTOMER1_30_0_, custome0_.NAME as NAME2_30_0_ where customer custome0_ where custome0_.CUSTOMER_PK=?
13:58:15.505 [http-nio-8080-exec-2] DEBUG o.h.SQL - select custome0_.CUSTOMER_PK as CUSTOMER1_30_0_, custome0_.NAME as NAME2_30_0_ where customer custome0_ where custome0_.CUSTOMER_PK=?
13:58:15.573 [http-nio-8080-exec-2] DEBUG o.h.SQL - select custome0_.CUSTOMER_PK as CUSTOMER1_30_0_, custome0_.NAME as NAME2_30_0_ where customer custome0_ where custome0_.CUSTOMER_PK=?
13:58:15.627 [http-nio-8080-exec-2] DEBUG o.h.SQL - select custome0_.CUSTOMER_PK as CUSTOMER1_30_0_, custome0_.NAME as NAME2_30_0_ where customer custome0_ where custome0_.CUSTOMER_PK=?
13:58:16.257 [http-nio-8080-exec-2] DEBUG o.h.SQL - select count(ord0_.ID) as col_0_0_ from order ord0_ where ord0_.DEALER_FK=?