Openbravo Issue Tracking System - Retail Modules
View Issue Details
0033709Retail ModulesWeb POSpublic2016-08-12 18:072016-08-29 09:59
shuehner 
shuehner 
normalminorhave not tried
closedfixed 
5
 
RR16Q4 
mtaal
No
0033709: Double query for posterminal in POSUtil.getLastDocumentNumber*ForPos
Those 3 functions in POSUtil do double query to OBPOS_Application each.

getLastDocumentNumberForPOS
getLastDocumentNumberQuotationForPOS
getLastDocumentNumberReturnForPOS

     OBCriteria<OBPOSApplications> termCrit = OBDal.getInstance().createCriteria(
         OBPOSApplications.class);
     termCrit.add(Restrictions.eq(OBPOSApplications.PROPERTY_SEARCHKEY, searchKey));
- if (termCrit.count() != 1) {

The code did explicit count() <> 1 check.
However as filter is for value field which has a unique constraint the case of >1 cannot happen.

So the count+list can be simplified to a simple .uniqueResult() followed by a != null check.
1.) Login into WebPOS
2.) Review queries done to obpos_applications coming from the above locations.

Notice .count() for each query followed by a select *
Performance
related to feature request 0033767 closed platform Openbravo ERP Add code to auto-detect 'accidental double query' on same OBQuery or OBCriteria object 
blocks design defect 0036898 new Triage Finance Openbravo ERP Performance issues when using DAL 
Issue History
2016-08-12 18:07shuehnerNew Issue
2016-08-12 18:07shuehnerAssigned To => Retail
2016-08-12 18:07shuehnerTriggers an Emergency Pack => No
2016-08-12 18:09shuehnerAssigned ToRetail => shuehner
2016-08-12 18:10shuehnerTag Attached: Performance
2016-08-23 14:45shuehnerRelationship addedrelated to 0033767
2016-08-23 15:40hgbotCheckin
2016-08-23 15:40hgbotNote Added: 0089309
2016-08-23 15:40hgbotStatusnew => resolved
2016-08-23 15:40hgbotResolutionopen => fixed
2016-08-23 15:40hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/f45d8a4e733bc770810df0ff283698c746f61970 [^]
2016-08-23 15:41shuehnerReview Assigned To => mtaal
2016-08-29 09:59mtaalNote Added: 0089484
2016-08-29 09:59mtaalStatusresolved => closed
2016-08-29 09:59mtaalFixed in Version => RR16Q4
2017-09-19 18:50markmm82Relationship addedblocks 0036898

Notes
(0089309)
hgbot   
2016-08-23 15:40   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: f45d8a4e733bc770810df0ff283698c746f61970
Author: Stefan Hühner <stefan.huehner <at> openbravo.com>
Date: Fri Aug 12 18:09:07 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/f45d8a4e733bc770810df0ff283698c746f61970 [^]

Fixed 33709. Avoid 3 extra queries during pos login.

The .count() != 1 triggers extra database query which can be avoided.
As the filter is for obpos_applications.value which has a unique constraint
the case of >1 cannot happen.

The 0 or 1 can be easily handled by the existing uniqueResult() call followed
by a simple == null check.

---
M src/org/openbravo/retail/posterminal/POSUtils.java
---
(0089484)
mtaal   
2016-08-29 09:59   
Reviewed and tested