0

I am trying to work on setting jdbcType to the parameters i pass to my Ibatis queries. My backend tables have fields defined as varchar and mybatis framework seems to be converting String parameters that i'm passing in my mapper.java to nvarchar. Query optimizer is taking time to verify execution plans as a result, doing the implicit type casting and hence some unexpected delays. any suggestions on getting around the problem?

A sample of what i have tried already: select * from myTable t where t.periodType=#{periodType, javaType="String", jdbcType = "varchar"}

the problem with this is, our query is quite big and it consists of a lot of subqueries where we pass the same parameter a few times. It's getting cumbersome to define the jdbcType for the same variable at every single occurence.

As parameterMap is deprecated I tried exploring parameterType. I passed a class to the parameterType but couldn't find a way to set jdbcType to variables in parameterType.

Any help is appreciated

schinta2
  • 23
  • 5

1 Answers1

1

parameterType will not work for you - this is the java type and rarely ever needed. One option I can think of is using

select * from myTable t where t.periodType=<include refid="PARAM_PERIOD_TYPE"/>

However this will makes the SQL unreadable. Only advantage is if changes are to be made they need to be only in the refered PARAM_PERIOD_TYPE sql tag.

6ton
  • 4,174
  • 1
  • 22
  • 37