java - In MyBatis, is there any solution for not adding jdbcType when setting null parameters? -


i'm using mybatis-3.2.8.jar , jdk 1.6.0_45.

the source table called emp:

> empno ename   job         mgr     hiredate            sal     comm  deptno  shortcut >  > 7499  allen   salesman    7698    1981/02/20 00:00:00 1600    300   30 null 

and sql this:

insert emp (empno, ename, job, mgr, hiredate, sal, comm, deptno, shortcut) values (#{empno},#{ename},#{job},#{mgr},#{hiredate},#{sal},#{comm},#{deptno},#{shortcut}); 

i'm using sql row row. select 1 row insert, again , again. or think table has 1 row.

then i'm facing error:

org.apache.ibatis.exceptions.persistenceexception:  #### error updating database.  cause: org.apache.ibatis.type.typeexception: error setting null parameter #7 jdbctype other . try setting different jdbctype parameter or different jdbctypefornull configuration property. cause: com.ibm.db2.jcc.am.sqlsyntaxerrorexception: db2 sql error: sqlcode=-104, sqlstate=42601, sqlerrmc=insert tb_ods_emp2(empno,ename,job,mgr;begin-of-statement;<grant>, driver=4.12.55 #### error may involve pdss5.hs.hdw.etltargetmapper.inserttargettable-inline #### error occurred while setting parameters #### sql: insert tb_ods_emp2(empno,ename,job,mgr,hiredate,sal,comm,deptno,shortcut) values(?,?,?,?,?,?,?,?,?) call getnextexception see cause #### cause: org.apache.ibatis.type.typeexception: error setting null parameter #7 jdbctype other . try setting different jdbctype parameter or different jdbctypefornull configuration property. cause: com.ibm.db2.jcc.am.sqlsyntaxerrorexception: db2 sql error: sqlcode=-104, sqlstate=42601, sqlerrmc=insert tb_ods_emp2(empno,ename,job,mgr;begin-of-statement;<grant>, driver=4.12.55  

my chief didn't want use jdbytype this:

insert emp (#{empno},#{ename},#{job},#{mgr},#{hiredate},#{sal},#{comm},#{deptno},`#{shortcut,jdbctype=varchar}`)  ...... 

in mybatis, there solution not adding jdbctype when setting null parameters?

i think adding jdbctype=varchar enough, chief hates (maybe...).

some databases don't allow untyped null sent in query should send or switching 1 database vendor might later cause sql fail.

see here explanations: is jdbctype necessary in mybatis mapper?

the jdbctype not mybatis requirement jdbc one. it's practice send jdbctype null parameters.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -