Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0016531Openbravo ERPA. Platformpublic2011-03-29 13:132011-06-13 10:57
adrianromero 
dalsasua 
normalminorsometimes
closedfixed 
5
pi 
3.0MP0 
Core
No
0016531: Cannot use null in a BaseOBObject parameter when calling a procedure
When using the class CallStoredProcedure to call a procedure and passing NULL in a parameter of type BaseOBObject an error is returned. If the value is not null it works
When calling a procedure pass a parameter using the following code:

types.add(org.openbravo.model.common.currency.ConversionRate.class);
parameters.add(null);

The problem is in the method getSQLType that raises an exception. In this particular case VARCHAR must be returned.
No tags attached.
blocks backport 00165412.50MP30 closed adrianromero Cannot use null in a BaseOBObject parameter when calling a procedure 
diff Fix-16531.diff (581) 2011-03-29 13:18
https://issues.openbravo.com/file_download.php?file_id=3777&type=bug
Issue History
2011-03-29 13:13adrianromeroNew Issue
2011-03-29 13:13adrianromeroAssigned To => mtaal
2011-03-29 13:13adrianromeroModules => Core
2011-03-29 13:18adrianromeroFile Added: Fix-16531.diff
2011-03-29 15:22adrianromeroIssue Monitored: adrianromero
2011-03-29 15:22adrianromeroIssue End Monitor: adrianromero
2011-03-29 15:22adrianromeroIssue Monitored: networkb
2011-03-29 15:58maiteNote Added: 0035335
2011-03-29 16:01adrianromeroStatusnew => scheduled
2011-03-29 16:01adrianromeroSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=1734#r1734
2011-03-29 16:02adrianromeroIssue cloned0016541
2011-03-29 16:02adrianromeroRelationship addedblocks 0016541
2011-03-31 17:13adrianromeroAssigned Tomtaal => adrianromero
2011-03-31 17:26hgbotCheckin
2011-03-31 17:26hgbotNote Added: 0035433
2011-03-31 17:26hgbotStatusscheduled => resolved
2011-03-31 17:26hgbotResolutionopen => fixed
2011-03-31 17:26hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/7d9ed704c9ceb4df05b49f73fac52ccf63d5f062 [^]
2011-03-31 17:34adrianromeroNote Added: 0035434
2011-06-03 10:58dalsasuaAssigned Toadrianromero => dalsasua
2011-06-13 10:57jonalegriaesarteNote Added: 0038284
2011-06-13 10:57jonalegriaesarteStatusresolved => closed
2011-06-13 10:57jonalegriaesarteFixed in Version => 3.0MP0

Notes
(0035335)
maite   
2011-03-29 15:58   
support_ticket=10946
due_date=03/06/2011
(0035433)
hgbot   
2011-03-31 17:26   
Repository: erp/devel/pi
Changeset: 7d9ed704c9ceb4df05b49f73fac52ccf63d5f062
Author: Adrián Romero <adrianromero <at> openbravo.com>
Date: Thu Mar 31 17:24:30 2011 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/7d9ed704c9ceb4df05b49f73fac52ccf63d5f062 [^]

Fixes issue 0016531: Cannot use null in a BaseOBObject parameter when calling a procedure
It has been modified the code to detect nulls when assigning as a procedure parameter a BaseOBObject

---
M src/org/openbravo/service/db/CallStoredProcedure.java
---
(0035434)
adrianromero   
2011-03-31 17:34   
* Testing the issue

Call an stored procedure passing a null value to a parameter of type BaseOBObject. For example the following code works:

List<Object> parameters = new ArrayList<Object>();
List<Class<?>> types = new ArrayList<Class<?>>();

types.add(BigDecimal.class);
parameters.add(new BigDecimal(120.0)); // Amount to covert: 120,00 €

types.add(String.class);
parameters.add("102"); // ID for EUR

types.add(String.class);
parameters.add("100"); // ID for USD

types.add(Date.class);
parameters.add(new Date()); // Conversion date

types.add(String.class);
parameters.add("S"); // ID for standard conversion type

types.add(String.class);
parameters.add("4028E6C72959682B01295A070852010D"); // ID for Sample Client

types.add(String.class);
parameters.add("0"); // ID for root organization "*"

BigDecimal strPrice = (BigDecimal)CallStoredProcedure.getInstance().call(
"C_CURRENCY_CONVERT", parameters, types);

System.out.println(strPrice);

But if you want to pass the Currency object as null should work too:

types.add(org.openbravo.model.common.currency.Currency.Class);
parameters.add(null);

The procedure will not calculate properly the change because it will be missing the currency parameter but the error described in this issue report will not appear

* Other areas affected

No other areas affected. Only the CallStoredProcedure class has been modified in the case of null parameters.
(0038284)
jonalegriaesarte   
2011-06-13 10:57   
Verified