Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033707Openbravo ERPA. Platformpublic2016-08-12 17:522016-08-26 13:21
shuehner 
shuehner 
normalminorhave not tried
closedfixed 
5
 
3.0PR16Q4 
caristu
Core
No
0033707: Accidental triple query in OBMessageUtils.getI18NMessage
This function has following code running 3 sql queries to retrieve a single row:

      if (messages.list().isEmpty()) {
        return null;
      }

      if (messages.list().size() > 1) {
        log4j.warn("More than one message found using key " + key);
      }

      // pick the first one
      final Message message = messages.list().get(0);

That code runs .list() 3 times for the same instance doing 3 queries
Also it does check for >1 result in the filter. However the fiter on ad_message is done one the value column (aka searchKey in DAL). As that column has a unique constraint in the database it is not possible to have >1 row so that extra check is not useful.

Both together allows all three .list() calls to be collapsed into a single .uniqueResult()
1.) Open 'Alert Management' via its button on top of UI
2.) Review queries done to ad_message

Performance
related to feature request 0033767 closed platform Add code to auto-detect 'accidental double query' on same OBQuery or OBCriteria object 
related to design defect 0036898 new Triage Finance Performance issues when using DAL 
Issue History
2016-08-12 17:52shuehnerNew Issue
2016-08-12 17:52shuehnerAssigned To => platform
2016-08-12 17:52shuehnerModules => Core
2016-08-12 17:52shuehnerTriggers an Emergency Pack => No
2016-08-12 18:09shuehnerAssigned Toplatform => shuehner
2016-08-12 18:09shuehnerTag Attached: Performance
2016-08-23 14:33hgbotCheckin
2016-08-23 14:33hgbotNote Added: 0089305
2016-08-23 14:33hgbotStatusnew => resolved
2016-08-23 14:33hgbotResolutionopen => fixed
2016-08-23 14:33hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/e905f809d4099d727be33163b651333ec7b01594 [^]
2016-08-23 14:34shuehnerReview Assigned To => caristu
2016-08-23 14:44shuehnerRelationship addedrelated to 0033767
2016-08-24 15:21caristuNote Added: 0089349
2016-08-24 15:21caristuStatusresolved => closed
2016-08-24 15:21caristuFixed in Version => 3.0PR16Q4
2016-08-25 11:01hgbotCheckin
2016-08-25 11:01hgbotNote Added: 0089386
2016-08-25 11:23hgbotCheckin
2016-08-25 11:23hgbotNote Added: 0089387
2016-08-25 22:53hudsonbotCheckin
2016-08-25 22:53hudsonbotNote Added: 0089415
2016-08-25 22:53hudsonbotCheckin
2016-08-25 22:53hudsonbotNote Added: 0089416
2016-08-26 08:23hgbotCheckin
2016-08-26 08:23hgbotNote Added: 0089424
2016-08-26 13:21hudsonbotCheckin
2016-08-26 13:21hudsonbotNote Added: 0089455
2017-09-19 18:50markmm82Relationship addedrelated to 0036898

Notes
(0089305)
hgbot   
2016-08-23 14:33   
Repository: erp/devel/pi
Changeset: e905f809d4099d727be33163b651333ec7b01594
Author: Stefan Hühner <stefan.huehner <at> openbravo.com>
Date: Fri Aug 12 17:54:08 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/e905f809d4099d727be33163b651333ec7b01594 [^]

Fixed 33707. Avoid triple query use single .uniqueResult instead.

Filter in that OBQuery is on 'value' field having uniqueConstraint. So not
checking for >1 rows in result is necessary as it can never happen, so remove
that check completely.

Collapse the other 2 .list() calls into a single .uniqueResult avoiding
yet another query.

---
M src/org/openbravo/erpCommon/utility/OBMessageUtils.java
---
(0089349)
caristu   
2016-08-24 15:21   
Code review + testing OK: now just one query is launched to retrieve the message
(0089386)
hgbot   
2016-08-25 11:01   
Repository: erp/devel/pi
Changeset: 51c44fe5c05702c37fd3d6f7e5657b14239d20aa
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Thu Aug 25 11:01:24 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/51c44fe5c05702c37fd3d6f7e5657b14239d20aa [^]

related to issue 33707: code review improvements

---
M src/org/openbravo/erpCommon/utility/OBMessageUtils.java
---
(0089387)
hgbot   
2016-08-25 11:23   
Repository: erp/devel/pi
Changeset: 70d44c2f8c70b2a080f01716d3668e8656570fa8
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Thu Aug 25 11:22:44 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/70d44c2f8c70b2a080f01716d3668e8656570fa8 [^]

related to issue 33707: reverting limit removal

---
M src/org/openbravo/erpCommon/utility/OBMessageUtils.java
---
(0089415)
hudsonbot   
2016-08-25 22:53   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/5e50832c9b35 [^]
Maturity status: Test
(0089416)
hudsonbot   
2016-08-25 22:53   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/5e50832c9b35 [^]
Maturity status: Test
(0089424)
hgbot   
2016-08-26 08:23   
Repository: erp/devel/pi
Changeset: 3a75b98096ef5a5d6f29c81133ca66e45e93d0ed
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Fri Aug 26 08:22:55 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/3a75b98096ef5a5d6f29c81133ca66e45e93d0ed [^]

related to issue 33707: updated copyright year

---
M src/org/openbravo/erpCommon/utility/OBMessageUtils.java
---
(0089455)
hudsonbot   
2016-08-26 13:21   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/f7253a361e2a [^]
Maturity status: Test