I am using 4.0.M5, previously this query worked as I expected:
ObjectSelect<Product> q = ObjectSelect.query(Product.class)
.where(Product.EXISTENCIAS_CORPORATIVAS.dot(StockCurrentCorporativo.UNITS).gt(0.0))
.and(Product.CODE.like("USBVGA");
List<Product> results = q.select(context);
The objective is to get products for which we have stock in any location,
StockCurrentCorporativo has the stock by location.
I restricted the example query to just one specific product and expect to get
only one product in results, but got results.size() > 1, with all items being
the same product (the same object on my tests).
The generated SQL from the log is:
SELECT <<all columns from t0 table>>
FROM public.products t0 JOIN public.stockcurrent_corporativo t1 ON (t0.id =
t1.product) WHERE (t1.units > ?) AND (t0.code LIKE ?) ORDER BY t0.name
[bind: 1->units:0.0, 2->code:'USBVGA']
EXISTENCIAS_CORPORATIVAS is a toMany relationship from Product and have type
StockCurrentCorporativo, defined in _Product as :
public static final Property<List<StockCurrentCorporativo>>
EXISTENCIAS_CORPORATIVAS = Property.create("existenciasCorporativas",
List.class);
To be fair, I do not know when this started, the production app is working
well, this is on a my development environment when I started to work for a new
requirement.
I reviewed the mapping and it looks ok, any help will be appreciated.
Atte. Juan Manuel Díaz Lara