Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033627Openbravo ERPA. Platformpublic2016-08-04 17:202016-08-30 10:07
shuehner 
mtaal 
normalminorhave not tried
closedfixed 
5
 
3.0PR16Q4 
alostale
Core
No
0033627: debug call in OBCriteria.count does trigger extra db query in some case
Given the following code:
    final OBCriteria<Locator> locators = OBDal.getInstance().createCriteria(Locator.class);
    locators.add(Restrictions.eq(Locator.PROPERTY_ACTIVE, true));
    locators.add(Restrictions.eq(Locator.PROPERTY_WAREHOUSE, shipment.getWarehouse()));
    if (locators.count() == 1) {

with 'shipment.getWarehouse() being a hibernate proxy (not initialized)

Then this debug statement inside OBCriteria.count()
      log.debug("Counting using criteria " + toString());

Triggers init + sql db read of m_warehouse which is not really required.

i.e. using POS OrderLoader which contains the above code (in some functional flow).
It maybe easier to reproduce in some small isolated test-case.
Wrap .debug in isDebugEnabled() to avoid calling toString() on it.
Performance
related to defect 0033139 closed mario_castello Retail Modules OrderLoader: Inefficient check for m_locator doing 2-3 queries for the same 
diff 33627.diff (753) 2016-08-04 17:22
https://issues.openbravo.com/file_download.php?file_id=9678&type=bug
Issue History
2016-08-04 17:20shuehnerNew Issue
2016-08-04 17:20shuehnerAssigned To => platform
2016-08-04 17:20shuehnerModules => Core
2016-08-04 17:20shuehnerTriggers an Emergency Pack => No
2016-08-04 17:21shuehnerTag Attached: Performance
2016-08-04 17:21shuehnerRelationship addedrelated to 0033139
2016-08-04 17:22shuehnerNote Added: 0088823
2016-08-04 17:22shuehnerFile Added: 33627.diff
2016-08-07 10:08mtaalAssigned Toplatform => mtaal
2016-08-07 16:25hgbotCheckin
2016-08-07 16:25hgbotNote Added: 0088868
2016-08-07 16:25hgbotStatusnew => resolved
2016-08-07 16:25hgbotResolutionopen => fixed
2016-08-07 16:25hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/2f8cbe2f7611ce4b89fe72e273a9c127c93bc952 [^]
2016-08-08 10:20mtaalReview Assigned To => alostale
2016-08-11 18:40hudsonbotCheckin
2016-08-11 18:40hudsonbotNote Added: 0089043
2016-08-30 10:07alostaleNote Added: 0089531
2016-08-30 10:07alostaleStatusresolved => closed
2016-08-30 10:07alostaleFixed in Version => 3.0PR16Q4

Notes
(0088823)
shuehner   
2016-08-04 17:22   
Mark as related as this issue here is trigger by the code change in 33139. So after fixing 33139 this bug here does not trigger anymore in that occasion (as the count call is removed).
(0088868)
hgbot   
2016-08-07 16:25   
Repository: erp/devel/pi
Changeset: 2f8cbe2f7611ce4b89fe72e273a9c127c93bc952
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Sun Aug 07 16:24:38 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/2f8cbe2f7611ce4b89fe72e273a9c127c93bc952 [^]

Fixes issue 33627: debug call in OBCriteria.count does trigger extra db query in some case
Wrap log.debug in if statement

---
M src/org/openbravo/dal/service/OBCriteria.java
---
(0089043)
hudsonbot   
2016-08-11 18:40   
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/edaa05b1fb18 [^]
Maturity status: Test
(0089531)
alostale   
2016-08-30 10:07   
code reviewed + tested