【发布时间】:2014-10-12 22:49:30
【问题描述】:
我正在尝试执行此插入:
@Insert("" +
"insert into EXTRANET.EX_ENTIDAD (ENT_REFNUM, ENT_TIPO, REG_PUB_ID, OFIC_REG_ID, AREA_REG_ID, " +
"COD_LIBRO, NUM_PARTIDA, ANO_TITU, NUM_TITU, ENT_TRIGGER, TMSTMP_CREA, PRIORIDAD) " +
" values (EXTRANET.EX_ENTIDAD_SEQ.nextval, #{entTipo}, " +
"#{regPubId}, #{oficRegId}, #{areaRegId}, #{codLibro}, #{numPartida}, #{anoTitu}, " +
" #{numTitu}, 'SYNC', SYSDATE, #{prioridad})")
public int insertEntidades(Map map);
但如果某些 #{param} 为 NULL,我得到它的错误:
原因:org.apache.ibatis.type.TypeException:使用 JdbcType NULL 为参数 #1 设置 null 时出错。尝试为此参数设置不同的 JdbcType 或不同的 jdbcTypeForNull
我正在寻找一些解决方案,并读到我必须配置一个属性:jdbcTypeForNull
然后我在 Spring 中更新我的配置:
@Bean
public SqlSessionFactoryBean sqlSessionFactory() throws Exception,Throwable {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(getDataSource());
//sessionFactory.setConfigLocation( new ClassPathResource("gob.pe.sunarp.extranet.config.config.xml"));
sessionFactory.setTypeAliasesPackage("gob.pe.sunarp.extranet.dao.beans");
final Properties sqlSessionFactoryProperties = new Properties();
sqlSessionFactoryProperties.put("jdbcTypeForNull", "NULL");
sessionFactory.setConfigurationProperties(sqlSessionFactoryProperties );
return sessionFactory;
}
但错误仍在继续。
我找到了许多 xml 的解决方案,但我只使用 java 接口。
关于这个错误的一些想法?
【问题讨论】:
标签: java spring oracle11g mybatis