Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0023538Openbravo ERPA. Platformpublic2013-04-12 10:302013-04-30 21:05
mirurita 
shankarb 
highmajoralways
closedno change required 
20Community Appliance
pi 
 
alostale
Core
No
0023538: Tab whereclause not resolving properly comparations of YesNo (boolean) reference columns.
1) As system admin mark FIN_Payment_Proposal.Isreceipt column as stored in session.
2) As system admin go to "Payment Proposal Pick and Edit Lines" window
 2.1) Edit the "Pick and Edit Lines" tab whereclause
replace e.salesTransaction = false
for
e.salesTransaction = @FIN_Payment_Proposal.receipt@
3) compile
4) Go to Payment Proposal window, create a new record and click on "Select Expected Payments" button

the value sent to the backend is
@FIN_Payment_Proposal.receipt@: false

5) See the error

2483ed25 1794036 [TP-Processor3] ERROR org.openbravo.service.json.DefaultJsonDataService - java.lang.String cannot be cast to java.lang.Boolean
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
    at org.hibernate.type.descriptor.java.BooleanTypeDescriptor.unwrap(BooleanTypeDescriptor.java:36)
    at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$1.doBind(VarcharTypeDescriptor.java:52)
    at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:91)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:282)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:277)
    at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:67)
    at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:571)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1716)
    at org.hibernate.loader.Loader.doQuery(Loader.java:801)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
    at org.hibernate.loader.Loader.doList(Loader.java:2533)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
    at org.hibernate.loader.Loader.list(Loader.java:2271)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.openbravo.dal.service.OBQuery.list(OBQuery.java:115)
1) As system admin mark FIN_Payment_Proposal.Isreceipt column as stored in session.
2) As system admin go to "Payment Proposal Pick and Edit Lines" window
 2.1) Edit the "Pick and Edit Lines" tab whereclause
replace e.salesTransaction = false
for
e.salesTransaction = @FIN_Payment_Proposal.receipt@
3) compile
4) Go to Payment Proposal window, create a new record and click on "Select Expected Payments" button

the value sent to the backend is
@FIN_Payment_Proposal.receipt@: false

5) See the error

2483ed25 1794036 [TP-Processor3] ERROR org.openbravo.service.json.DefaultJsonDataService - java.lang.String cannot be cast to java.lang.Boolean
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
    at org.hibernate.type.descriptor.java.BooleanTypeDescriptor.unwrap(BooleanTypeDescriptor.java:36)
    at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$1.doBind(VarcharTypeDescriptor.java:52)
    at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:91)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:282)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:277)
    at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:67)
    at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:571)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1716)
    at org.hibernate.loader.Loader.doQuery(Loader.java:801)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
    at org.hibernate.loader.Loader.doList(Loader.java:2533)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
    at org.hibernate.loader.Loader.list(Loader.java:2271)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.openbravo.dal.service.OBQuery.list(OBQuery.java:115)
the following workaround works:

e.salesTransaction = (case when @FIN_Payment_Proposal.receipt@='true' then 'Y' else 'N' end)

No tags attached.
diff 23538.diff (1,343) 2013-04-23 10:17
https://issues.openbravo.com/file_download.php?file_id=6108&type=bug
Issue History
2013-04-12 10:30miruritaNew Issue
2013-04-12 10:30miruritaAssigned To => AugustoMauch
2013-04-12 10:30miruritaModules => Core
2013-04-12 10:30miruritaTriggers an Emergency Pack => No
2013-04-16 11:59shankarbAssigned ToAugustoMauch => shankarb
2013-04-23 10:17shankarbFile Added: 23538.diff
2013-04-28 08:40shankarbIssue Monitored: AugustoMauch
2013-04-28 08:40shankarbReview Assigned To => AugustoMauch
2013-04-28 08:40shankarbStatusnew => scheduled
2013-04-28 08:40shankarbfix_in_branch => pi
2013-04-28 09:56hgbotCheckin
2013-04-28 09:56hgbotNote Added: 0058294
2013-04-28 09:56hgbotStatusscheduled => resolved
2013-04-28 09:56hgbotResolutionopen => fixed
2013-04-28 09:56hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/5e5dd4a8b5c000c0f6ae0f1e8469cd7b6c708200 [^]
2013-04-29 19:37hudsonbotCheckin
2013-04-29 19:37hudsonbotNote Added: 0058312
2013-04-30 11:10hgbotCheckin
2013-04-30 11:10hgbotNote Added: 0058331
2013-04-30 11:10alostaleStatusresolved => new
2013-04-30 11:10alostaleResolutionfixed => open
2013-04-30 11:14alostaleReview Assigned ToAugustoMauch => alostale
2013-04-30 11:14alostaleNote Added: 0058332
2013-04-30 11:14alostaleStatusnew => closed
2013-04-30 11:14alostaleResolutionopen => no change required
2013-04-30 21:05hudsonbotCheckin
2013-04-30 21:05hudsonbotNote Added: 0058390

Notes
(0058294)
hgbot   
2013-04-28 09:56   
Repository: erp/devel/pi
Changeset: 5e5dd4a8b5c000c0f6ae0f1e8469cd7b6c708200
Author: Shankar Balachandran <shankar.balachandran <at> openbravo.com>
Date: Sun Apr 28 12:45:45 2013 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/5e5dd4a8b5c000c0f6ae0f1e8469cd7b6c708200 [^]

Fixes Issue 0023538: Tab whereclause not resolving properly

Tab whereclause now resolves properly comparations of YesNo (boolean) reference columns.Type casted the typedParameter to boolean when substituting the value.

---
M modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
---
(0058312)
hudsonbot   
2013-04-29 19:37   
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/10fc6569028b [^]

Maturity status: Test
(0058331)
hgbot   
2013-04-30 11:10   
Repository: erp/devel/pi
Changeset: c29fbfed2534706ce58c0bd3b2abc038e1f748eb
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Tue Apr 30 11:09:35 2013 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/c29fbfed2534706ce58c0bd3b2abc038e1f748eb [^]

backed out changest related to issue 23538

All values for paramters are treated as String, as it is not possible at this
point to determine the type they should be. Converting "true" and "false" literals
to boolean values can fail in case the property they are compared to is not a
boolean.

---
M modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
---
(0058332)
alostale   
2013-04-30 11:14   
This is not going to be changed.

The proposed fix assumed "true" and "false" literals are always boolean doing the conversion based on that. This causes an API change (if a query uses the workaround explained in the use, it would stop working after the fix).

The problem is at the evaluation point it is not possible to determine for a parameter which is the type it should take and guessing it can cause problems.

In addition, other types are not converted from String. For example in the same query, dates are passed as String and transformed within the query itself.
(0058390)
hudsonbot   
2013-04-30 21:05   
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/3ea22ca7a348 [^]

Maturity status: Test