Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033794Openbravo ERPA. Platformpublic2016-08-24 14:212016-08-26 13:21
shuehner 
shuehner 
normalminorhave not tried
closedfixed 
5
 
3.0PR16Q4 
caristu
Core
No
0033794: Accidental double queries in DataSourceServiceProvider.getDataSourceFromDataSourceName
That function calls .list() twice on same instance leading do sql query run twice.

As the filter used is for a field (name) having a unique constraint double .list() usage can be simplified to just .uniqueResult as the case of >1 result rows cannot happen.
with debugging code from https://issues.openbravo.com/view.php?id=33767 [^] applied
run try (erp) and observe debugging output during try-initial-pgsql job

Unknwown which exact UI action triggers this special case which is 'get datasourceByName compared to getting it byId.

See logic in getRealDataSource for the difference in calling.
Performance
related to feature request 0033767 closed platform Add code to auto-detect 'accidental double query' on same OBQuery or OBCriteria object 
Issue History
2016-08-24 14:21shuehnerNew Issue
2016-08-24 14:21shuehnerAssigned To => platform
2016-08-24 14:21shuehnerModules => Core
2016-08-24 14:21shuehnerTriggers an Emergency Pack => No
2016-08-24 14:21shuehnerTag Attached: Performance
2016-08-24 14:21shuehnerRelationship addedrelated to 0033767
2016-08-24 14:24hgbotCheckin
2016-08-24 14:24hgbotNote Added: 0089345
2016-08-24 14:24hgbotStatusnew => resolved
2016-08-24 14:24hgbotResolutionopen => fixed
2016-08-24 14:24hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/4dddd6f401c6cf36a2aa5af49458abe2f8c5280f [^]
2016-08-24 14:24shuehnerReview Assigned To => caristu
2016-08-24 15:00shuehnerAssigned Toplatform => shuehner
2016-08-25 10:52caristuNote Added: 0089385
2016-08-25 10:52caristuStatusresolved => closed
2016-08-25 10:52caristuFixed in Version => 3.0PR16Q4
2016-08-26 08:25hgbotCheckin
2016-08-26 08:25hgbotNote Added: 0089425
2016-08-26 13:21hudsonbotCheckin
2016-08-26 13:21hudsonbotNote Added: 0089456

Notes
(0089345)
hgbot   
2016-08-24 14:24   
Repository: erp/devel/pi
Changeset: 4dddd6f401c6cf36a2aa5af49458abe2f8c5280f
Author: Stefan Hühner <stefan.huehner <at> openbravo.com>
Date: Wed Aug 24 14:23:41 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/4dddd6f401c6cf36a2aa5af49458abe2f8c5280f [^]

Fixed 33794. Avoid double .list() call by using .uniqueResult() instead.

Code did check for >1 result rows while reading from obserds_datasource.
However as the filter is on the name column and that column has an unique
constraint that case of >1 cannot happen.

So simplify to just call .uniqueResult() removing both .list() calls.

---
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java
---
(0089385)
caristu   
2016-08-25 10:52   
Code reviewed
(0089425)
hgbot   
2016-08-26 08:25   
Repository: erp/devel/pi
Changeset: 6914648cfa1df0c0e6a305a83addadaee01b8f22
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Fri Aug 26 08:24:54 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/6914648cfa1df0c0e6a305a83addadaee01b8f22 [^]

related to issue 33794: updated copyright year

---
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServiceProvider.java
---
(0089456)
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