details: https://code.openbravo.com/erp/devel/pi/rev/35265c987291 changeset: 26181:35265c987291 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Wed Mar 11 11:07:30 2015 +0100 summary: Fixes issue 29224: Return reason filter works properly in Return from/to P&E
The problem was that in this changeset [1] the way the distinct queries (done to populate the fk filter dropdowns) was modified. The query is different, and the way to process its results too. The regressi on was caused because some HQL tables build their distinct queries manually in their HQL transformers, and those queries should have been updated too. The query was changed the whole BaseOBObject in the first position of the result array, instead of including just its id. [1] https://code.openbravo.com/erp/devel/pi/rev/95dd177fbbc7f18d448b3e31cc12b67dbc0cb87d details: https://code.openbravo.com/erp/devel/pi/rev/f906f479f709 changeset: 26182:f906f479f709 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Wed Mar 11 11:07:30 2015 +0100 summary: Fixes issue 29224: Filters work properly in Return from/to P&E window The problem was that in this changeset [1] the way the distinct queries (done to populate the fk filter dropdowns) was modified. The query is different, and the way to process its results too. The change done in the result processing caused this issue. The query done to populate the Attribute Set Value drop down is the following: select distinct attributeSetValue,attributeSetValue.description FROM MaterialMgmtShipmentInOutLine as iol left join iol.attributeSetValue as attributeSetValue join iol.shipmentReceipt as io where io.businessPartner.id = 'A6750F0D15334FB890C254369AC750A8' and io.processed = true and io.documentStatus <> 'VO' and io.salesTransaction = true and (select iol.salesOrderLine.orderDiscount from MaterialMgmtShipmentInOutLine as e where e.id = iol) is null and iol.client.id in ('0', '23C59575B9CF467C9620760EB255B389') AND iol.organization in ('E443A31992CB4635AFCAEABE7183CE85','0','19404EAD144C49A0AF37D54377CF452D','B843C30461EA4501935CB1D125C9C25A') AND (io.movementDate >= (now() - 90) or (case when (select ('Y') from OrderLine as ol where ol.salesOrder.id = 'F0D6700E7BD6499FA76C6D94014714E8' and ol.goodsShipmentLine = iol) is null then false else true end) = true) ORDER BY attributeSetValue.description And this is the result returned in the test I did: 1 42EA0E631BDD4ED69D8C30723A5E81C8 [identifier: L582, entity: AttributeSetInstance], L582 2 NULL, NULL With the previous way of processing the results the second record was ignored, but with the new one a NPE was being thrown. [1] https://code.openbravo.com/erp/devel/pi/rev/95dd177fbbc7f18d448b3e31cc12b67dbc0cb87d diffstat: modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java | 3 +++ src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java | 2 +- src/org/openbravo/common/datasource/ReturnToFromCustomerVendorOrphanHQLTransformer.java | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diffs (37 lines): diff -r ee85914ad233 -r f906f479f709 modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java --- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java Fri Mar 13 17:39:41 2015 +0000 +++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java Wed Mar 11 11:07:30 2015 +0100 @@ -182,6 +182,9 @@ Object[] result = (Object[]) row; // the whole referenced BaseOBObject is stored in the first position of the result BaseOBObject bob = (BaseOBObject) result[0]; + if (bob == null) { + break; + } record.put(JsonConstants.ID, bob.getId()); record.put(JsonConstants.IDENTIFIER, IdentifierProvider.getInstance().getIdentifier(bob)); } else { diff -r ee85914ad233 -r f906f479f709 src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java --- a/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java Fri Mar 13 17:39:41 2015 +0000 +++ b/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java Wed Mar 11 11:07:30 2015 +0100 @@ -39,7 +39,7 @@ private static final String returnedOthersLeftClause = " coalesce((select sum(ol.orderedQuantity) from OrderLine as ol left join ol.salesOrder as o where ol.goodsShipmentLine = iol and o.processed = true and o.documentStatus <> 'VO'), 0)"; private static final String returnReasonLeftClause = " coalesce((select ol.returnReason.id from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), '')"; private static final String returnReasonCountQuery = " select count(distinct e.name) from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is not null) "; - private static final String returnReasonDataQuery = " select distinct e.id, e.name from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is not null) "; + private static final String returnReasonDataQuery = " select distinct e, e.name from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is not null) "; private static final String unitPriceProperty = "unitPrice"; private static final String grossUnitPriceProperty = "grossUnitPrice"; diff -r ee85914ad233 -r f906f479f709 src/org/openbravo/common/datasource/ReturnToFromCustomerVendorOrphanHQLTransformer.java --- a/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorOrphanHQLTransformer.java Fri Mar 13 17:39:41 2015 +0000 +++ b/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorOrphanHQLTransformer.java Wed Mar 11 11:07:30 2015 +0100 @@ -34,7 +34,7 @@ private static final String returnReasonLeftClause = " coalesce((select oli.returnReason.id from OrderLine as oli where oli.salesOrder.id = :salesOrderId and oli.id=ol.id), '')"; private static final String returnReasonCountQuery = " select count(distinct e.name) from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is null) "; - private static final String returnReasonDataQuery = " select distinct e.id, e.name from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is null) "; + private static final String returnReasonDataQuery = " select distinct e, e.name from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is null) "; @Override public String transformHqlQuery(String hqlQuery, Map<String, String> requestParameters, ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits