gpt4 book ai didi

hibernate - 在 HQL 中连接多个表

转载 作者:行者123 更新时间:2023-12-03 14:01:21 26 4
gpt4 key购买 nike

谁能帮我将此查询转换为 HQL

SELECT      
supplierOrderDetails.productID,
supplierOrderDetails.orderQty,
supplierOrderReceiveDetail.qtyArrived
FROM
supplierOrder
INNER JOIN
supplierOrderDetails
ON
(supplierOrderDetails.supplierOrderID = supplierOrder.ID)
INNER JOIN
supplierOrderReceive
ON
(supplierOrderReceive.supplierOrderID = supplierOrder.ID)
INNER JOIN
supplierOrderReceiveDetail
ON
(supplierOrderReceiveDetail.supplierOrderReceiveID = supplierOrderReceive.ID)
AND
(supplierOrderReceiveDetail.ProductID =supplierOrderDetails.ProductID)
WHERE supplierOrder.ID = 1

这是表关系

enter image description here

最佳答案

我已经为那些想知道如何在 HQL 中加入多个表的人添加了查询

SELECT supplierOrderDetails.productID as product, supplierOrderDetails.orderQty as orderedQty,sum(supplierOrderReceiveDetail.qtyArrived) as qtyArrived 

FROM SupplierOrder as so, SupplierOrderDetails as supplierOrderDetails, SupplierOrderReceiveDetail as supplierOrderReceiveDetail, SupplierOrderReceive as supplierOrderReceive

INNER JOIN supplierOrderDetails.supplierOrderID

INNER JOIN supplierOrderReceive.supplierOrder

INNER JOIN supplierOrderReceiveDetail.supplierOrderReceive

GROUP BY supplierOrderDetails.productID, supplierOrderDetails.orderQty

关于hibernate - 在 HQL 中连接多个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20758398/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com