我試圖讓這個查詢在JPAMySQL查詢完美運行,但JPA查詢返回任何
工作它完全在MySQL:返回
select * from order_header join order_detail where (order_header.buying_partner_id = 1 or order_header.buying_partner_id = 3) AND ((order_detail.warehouse_id = 6) or (order_header.warehouse_id = 6 and order_detail.warehouse_id is null)) and (order_detail.tracking_number is null or order_detail.tracking_number = '') and order_detail.canceled != 1 and (order_header.order_num is NOT NULL and order_header.order_num != '') and order_header.timestamp > '2017-01-24 08:33:00.096' group by order_header.order_num order by order_header.comment DESC;
結果。
JPA查詢:
Select h FROM OrderHeader h JOIN h.orderDetails d WHERE (h.buyingPartner.id = 1 or h.buyingPartner.id = 3) AND ( (d.warehouse.id =6) OR (h.warehouse.id =6 AND d.warehouse.id IS null ) ) AND (d.trackingNumber IS null or d.trackingNumber = '') AND d.canceled != 1 AND (h.orderNum IS NOT null AND h.orderNum != '') and h.timestamp > '2017-01-24 09:32:39.865' GROUP BY h.orderNum ORDER BY h.comment DESC
它沒有返回。沒有錯誤。只是沒有返回。
這些是完全相同的陳述。
我的JPA聲明一定有問題。
嗯,我看到了很多不同'order_header'和'OrderHeader' ...'order_detail' vs orderDetails ...在我看來他們不是相同的陳述.... –