Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0037112Openbravo ERPA. Platformpublic2017-10-19 10:212018-01-03 12:38
alostale 
alostale 
normalminorhave not tried
closedfixed 
5
 
3.0PR18Q1 
caristu
Core
No
0037112: incorrect HQL to retrieve preferences
When retrieving preferences without organization, the HQL that is generated has unbalanced parentheses.

Even it's an incorrect HQL, Hibernate manages to somehow generate a valid SQL (although it removes some parts).

Note that most of the times organization parameter is used, this issue appears only when it is not. Main user is login page that has not organization yet.

This same HQL fails in newer (5.2) Hibernate versions.
Open login page and check hql generated for ForcedLoginURL preference [1] and the SQL it's finally executed.

HQL:
 as p  
 where (coalesce(p.visibleAtClient, '0')='0')  
 and (p.visibleAtRole is null)      
 and (coalesce(p.visibleAtOrganization, '0')='0')) 
 and (p.userContact is null)  
 and (p.window is null)  
 and p.propertyList = 'Y' 
 and p.property = ?  
 order by p.AD_Window_ID


SQL:
  ...
  from AD_Preference adpreferen0_ 
  where coalesce(adpreferen0_.VisibleAt_Client_ID, '0')='0' 
  and (adpreferen0_.VisibleAt_Role_ID is null) 
  and coalesce(adpreferen0_.VisibleAt_Org_ID, '0')='0' 
  and (adpreferen0_.AD_User_ID is null) 
  and (adpreferen0_.AD_Window_ID is null) 
  and adpreferen0_.IsPropertyList='Y' 
  and adpreferen0_.Property=?


Removing the extra parenthesis in the HQL, the correct SQL is:
  from AD_Preference adpreferen0_ 
  where coalesce(adpreferen0_.VisibleAt_Client_ID, '0')='0' 
  and (adpreferen0_.VisibleAt_Role_ID is null) 
  and coalesce(adpreferen0_.VisibleAt_Org_ID, '0')='0' 
  and (adpreferen0_.AD_User_ID is null) 
  and (adpreferen0_.AD_Window_ID is null) 
  and adpreferen0_.IsPropertyList='Y' 
  and adpreferen0_.Property=? 
  and (adpreferen0_.AD_Org_ID in ('0'))
  and (adpreferen0_.AD_Client_ID in ('0')) 
  and adpreferen0_.IsActive='Y' 
  order by adpreferen0_.AD_Preference_ID


---
[1] https://code.openbravo.com/erp/devel/pi/file/c77412df1f7e/src/org/openbravo/erpCommon/businessUtility/Preferences.java#l455 [^]
No tags attached.
related to defect 0037130 closed marvintm Retail Modules Terminal authentication is being activated even if the preference is set to 'N' 
related to defect 0038655 closed alostale Openbravo ERP incorrect query in UserLock 
blocks feature request 0037064 closed caristu Openbravo ERP upgrade hibernate to 5.3.2 
blocks defect 0037324 closed alostale Openbravo ERP slow login having many preferences 
Issue History
2017-10-19 10:21alostaleNew Issue
2017-10-19 10:21alostaleAssigned To => platform
2017-10-19 10:21alostaleModules => Core
2017-10-19 10:21alostaleTriggers an Emergency Pack => No
2017-10-19 10:22alostaleAssigned Toplatform => alostale
2017-10-19 10:32alostaleRelationship addedblocks 0037064
2017-10-19 10:36alostaleReview Assigned To => caristu
2017-10-19 10:36alostaleSummaryincorrect HQL in Preferences => incorrect HQL to retrieve preferences
2017-10-19 10:36alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=16141#r16141
2017-10-19 10:49hgbotCheckin
2017-10-19 10:49hgbotNote Added: 0099958
2017-10-19 10:49hgbotStatusnew => resolved
2017-10-19 10:49hgbotResolutionopen => fixed
2017-10-19 10:49hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/27acf774fde2f2ef8ca8d60c27f5b522db6e43e3 [^]
2017-10-20 10:21marvintmRelationship addedrelated to 0037130
2017-10-27 10:27caristuNote Added: 0100094
2017-10-27 10:27caristuStatusresolved => closed
2017-10-27 10:27caristuFixed in Version => 3.0PR18Q1
2017-11-20 12:12alostaleRelationship addedblocks 0037324
2018-01-03 12:38hudsonbotCheckin
2018-01-03 12:38hudsonbotNote Added: 0101338
2018-05-30 10:28alostaleRelationship addedrelated to 0038655

Notes
(0099958)
hgbot   
2017-10-19 10:49   
Repository: erp/devel/pi
Changeset: 27acf774fde2f2ef8ca8d60c27f5b522db6e43e3
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Oct 19 10:25:31 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/27acf774fde2f2ef8ca8d60c27f5b522db6e43e3 [^]

fixed bug 37112: incorrect HQL to retrieve preferences

  Removed extra unbalanced parentheses when organization parameter is null.

---
M src/org/openbravo/erpCommon/businessUtility/Preferences.java
---
(0100094)
caristu   
2017-10-27 10:27   
Code reviewed + tested OK.
(0101338)
hudsonbot   
2018-01-03 12:38   
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/c81e0d3cbab5 [^]
Maturity status: Test