0

We have a Oracle procedure call done using iBatis. One of the IN parameters to the procedure is a VARCHAR2 datatype in procedure and is java.lang.String in Service/DAO layers.

The procedure fails whenever this input parameter is passed with NULL value. When a value is passed, then the procedure gets called without any errors.

For this procedure parameter (which is nullable) within the parametermap, we set the attribute as jdbctype="java.sql.Types.NULL" and it started working.

Is this the correct solution ?

The database connection is established using connection pool (dbcp) created in Tomcat6 server.

Community
  • 1
  • 1
yathirigan
  • 5,619
  • 22
  • 66
  • 104

2 Answers2

0

Ibatis for sure have problems with NULL values passed as parameters. In our insert query we use such wrapper:

insert into table (column1) values (<isNull property="column1">NULL </isNull><isNotNull property="column1">#column1:INT# </isNotNull>)
Olesia
  • 144
  • 4
  • this works for in-line parameter mapping. but how do you manage when there are mapping is done via parameter tag ? – yathirigan Sep 08 '12 at 10:14
  • What do you mean by "parameter tag"? In example above "column1" is the property of the class defined in the parameterClass tag. For example or . In last case you will fill map with your parameters and pass this map to the ibatis. – Olesia Sep 13 '12 at 10:21
  • by parameter tag i meant the following { call getEmp( #acctID# ) } – yathirigan Sep 18 '12 at 03:45
0

for those still using the old version of ibatis (2.3 in my case), the above error while passing nullable parameters might be caused by not specifying jdbcType in parameterMap. there is a passage in iBatis 2.3.0 User Guide (p.27, Parameter Maps and Inline Parameters - jdbcType) pointing that out.

hello_earth
  • 1,442
  • 1
  • 25
  • 39