QueryDSL combines two levels with bi-directional communication

I am looking for QueryDSL help.

I have three tables. 1) Order 2) Details 3) Lines

An order can contain multiple parts and parts that can have multiple lines.

So, I have in my OrderDO

// bi-directional many-to-one association to FociRequestDetail
    @OneToMany(mappedBy = "omsOrder")
    private List<FociRequestDetailDO> fociRequestDetails;

      

and in DetailsDO

    // bi-directional many-to-one association to FociRequestLine
    @OneToMany(mappedBy = "fociRequestDetail")
    private List<FociRequestLineDO> fociRequestLines;

@ManyToOne
    @JoinColumn(name = "OMS_ORDER_ID")
    private OmsOrderDO omsOrder;

      

and in LinesDO

@ManyToOne
    @JoinColumn(name = "REQUEST_DETAIL_ID")
    private FociRequestDetailDO fociRequestDetail;

      

I want to query all details and lines for a given orderId = 12345

So my result should have one object or OrderDO OrderDO as it can be one for a given OrderId - DO details should be multiple or one based on orderId ---- DO rows should be multiple or one based on detailId

I've tried doing .from (orderDO) .join (orderDO.fociRequestDetails, fociRequestDetailDO). Where (orderDO.orderId.eq (OrderNo));

it gives me two OrderDO objects. Ideally, it should only return one object and two details.

Please suggest how should I achieve this with a single Order object and its child of the parts and then its child inside the parts.

+3


source to share





All Articles