I have the following optional, to-many relationship: PackingSlip <->> LineItem
I need to match all the PackingSlip
instances that do not have any related LineItem
instances with an qtyOrdered
> qtyShipped
.
What makes the most sense to me would be to write an expression along the lines of:
PackingSlip.LINE_ITEMS.containsMatch(LineItem.QTY_ORDERED.lt(LineItem.QTY_SHIPPED)).notExp();
Which I would expect to generate SQL along the lines of:
SELECT t0.id, ... FROM packing_slip t0
WHERE NOT (
EXISTS (
SELECT * FROM line_item t1
WHERE t1.packing_slip_id = t0.id
AND t1.qty_ordered < t1.qty_shipped
)
)
Obviously, I've made up the containsMatch(Expression)
method. Since such a thing does not exist (currently), what is the best way of accomplishing this in Cayenne 4.0?