Showing posts with label iBatis. Show all posts
Showing posts with label iBatis. Show all posts

28 Feb 2013

org.springframework.jdbc.UncategorizedSQLException: Error setting null parameter.

Problem: org.springframework.jdbc.UncategorizedSQLException: Error setting null parameter. Most JDBC drivers require that the JdbcType must be specified for all nullable parameters.

Cause: The JdbcType property is not set in the XML mapper.

Solution: Specify jdbcType of the parameter in the mapper.

<select id="selectByYear" parameterType="map" resultMap="BaseResultMap"> SELECT * FROM tbl_calendar WHERE year=#{year,jdbcType=DECIMAL} </select>

22 Feb 2013

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for

Problem: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for

Cause: The same namespace is used in 2 different mappers.

Solution: Change the namespace in one of the mappers.

<?mapper namespace="com.blogspot.adaprognotebook.dao.mybatis.CompanyMapper" >

Exception getting JDBC Driver

Problem: When generating the iMbatis mapping files in Eclipse, "Fail to generate mapper files: Exception getting JDBC Driver" error is encountered.

Figure 1: Exception getting JDBC Driver

Cause: Eclipse cannot find the JDBC library file.

Solution: Add <classPathEntry> to the "generatorConfig.xml" to define the class path of the library file.

generatorConfig.xml

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > <generatorConfiguration> <classPathEntry location="/Users/adaprognotebook/lib/ojdbc6.jar"/> <context id="system" > <plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin" /> <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@//127.0.0.1:1521/books" userId="ada" password="pass123" /> <javaModelGenerator targetPackage="com.blogspot.adaprognotebook.model" targetProject="books" /> <sqlMapGenerator targetPackage="com.blogspot.adaprognotebook.dao.mybatis.mapper" targetProject="books/src/conf" /> <javaClientGenerator targetPackage="com.blogspot.adaprognotebook.dao.mybatis" targetProject="books" type="XMLMAPPER" /> <table schema="books" tableName="AUTHROS" /> </context> </generatorConfiguration>