Problem code:
<select id="selectIstars" parameterType="java.lang.String" resultType="java.lang.String"> SELECT stars FROM book WHERE 1 = 1 <if test="id != null"> AND id = #{id,jdbcType=VARCHAR} </if> </select>
This is the problem with the final positioning code, which has been roughly understood by many online references:
There is a difference between the judgment of single parameter and multi parameter. When our input parameter is an entity class or map, there is no problem using the if parameter.
But when our input parameter is java.lang.integer or java.lang.string, we need to pay attention to some things
For integer type input parameters, add this
#{id,jdbcType=integer}
There is a problem with the input parameter of string type. I also added it
#{id,jdbcType=VARCHAR}
It still reported an error. Finally, the if judgment was deleted and the problem was solved, but it was still confused. If a big man understands it, please give me some advice
Similar Posts:
- [Solved] org.apache.ibatis.binding.BindingException: Parameter ‘area_id’ not found. Available parameters are [areaId, param1]
- [Solved] Error setting null for parameter #6 with JdbcType OTHER…
- [Solved] Mybatis multi-table query error: Column ‘id’ in field list is ambiguous
- [Solved] mapper.xml Error: java.lang.AbstractMethodError: Method oracle/jdbc/driver/OracleResultSetImpl.getNString(Ljava/lang/String;)Ljava/lang/String; is abstract,
- Several cases of error reporting in java.lang.nullpointerexception
- Python calculator error: can’t multiply sequence by non-int of type ‘float’
- [Solved] PyCharm Start Error: TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’
- [Solved] Spark Streaming:updateStateByKey is not applicable for the arguments…
- [Solved] Android.content.res.Resources$NotFoundException: String resource ID #0x0
- [Solved] Mybatis error: attempted to return null from a method with a primitive return type (int)