向mysql中插入过期日期,报错为:
登录异常nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='expired', mode=IN, javaType=class java.util.Date, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
一直以为是mysql插入日期对格式有要求,遍历各种方法之后看到一个博客发现是自己的insert语句的问题。。。
@Insert({"insert into ", TABLE_NAME, "(", INSERT_FIELDS,") values (#userId}, #{expired}, #{status}, #{ticket})" })
就是#userId少了一个{
正确为
@Insert({"insert into ", TABLE_NAME, "(", INSERT_FIELDS,") values (#{userId}, #{expired}, #{status}, #{ticket})" })
太坑,记录一下