Re: Problem using to-many relationship on where clause

2017-11-29 Thread Juan Manuel Diaz Lara
Workaround: Changed mapping from LONGVARBINARY to  BINARY (DefaultSelectTranslator#isUnsupportedForDistinct does not catch this type as unsupported). Atte. Juan Manuel Díaz Lara On Wednesday, November 29, 2017, 9:15:27 AM CST, Nikita Timofeev wrote: Answered at dev@ list, but leave

Re: Problem using to-many relationship on where clause

2017-11-29 Thread Nikita Timofeev
Answered at dev@ list, but leave a note here too. Looks like a bug to me too. Will investigate and file a bug (and ideally make a fix) if required. On Wed, Nov 29, 2017 at 9:17 AM, Juan Manuel Diaz Lara wrote: > I created a new project, with entities Products -toMany-> > StockcurrentCorporativo,

Re: Problem using to-many relationship on where clause

2017-11-28 Thread Juan Manuel Diaz Lara
I created a new project, with entities Products -toMany-> StockcurrentCorporativo, with same results. Tracing code, I arrived to DefaultSelectTranslator#isUnsupportedForDistinct, this is the cause for cayenne not including a DISTINCT in generated SQL, because I have columns mapping to types "not

Re: Problem using to-many relationship on where clause

2017-11-28 Thread Juan Manuel Diaz Lara
I am agree that this kind of query should generate a SQL DISTINCT, but the fact is that adding a joint()brings only one product on result even the sql generates 16 rows, so Cayenne is doing some kind of IN-MEMORY DISTINCT that is not done without a joint(), maybe a bug because there are two diff

Re: Problem using to-many relationship on where clause

2017-11-28 Thread Lon Varscsak
I think the part that's missing is a "distinct". I'm assuming there are 4 stockcurrent_corporativo rows for that one product, but if it had a distinct it would be showing one. I don't think that ObjectSelect/FluentSelect have the ability to turn on/off distinct, but for me, this always generates

Re: Problem using to-many relationship on where clause

2017-11-27 Thread Juan Manuel Diaz Lara
More details, this code should return only one product entity, but produces a result list with 4 items, all items being the same product entity (the purpose is get products which have stock in at leas one location): ObjectSelect q = ObjectSelect.query(Product.class)  .where(Product.EXISTENCIAS

Problem using to-many relationship on where clause

2017-11-26 Thread Juan Manuel Diaz Lara
I am using 4.0.M5, previously this query worked as I expected: ObjectSelect q = ObjectSelect.query(Product.class)                  .where(Product.EXISTENCIAS_CORPORATIVAS.dot(StockCurrentCorporativo.UNITS).gt(0.0))     .and(Product.CODE.like("USBVGA");