首先来写下我先在遇到的问题:
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='pkEmailInfoId', mode=IN, javaType=long, 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).
### The error may involve com.scut.emos.dao.MailMapper.createInfo-Inline
### The error occurred while setting parameters
### SQL: ` INSERT INTO tb_email_info (pk_email_info_id, project_id, email_name, email_address, password, auth_code, protocol, server_host, create_time) VALUES (?, ?, ?,?, ?, ?, ?, ?, ?)
### Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='pkEmailInfoId', mode=IN, javaType=long, 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).
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy146.createInfo(Unknown Source)
... 96 more
Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='pkEmailInfoId', mode=IN, javaType=long, 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).
但是前面我在程序中利用System.out.println()输出发现
在我传入的对象中,是有数据存在的,那么现在问题出自什么地方呢?
但是后来我上网查的说什么是因为xml文件里面有注释的,但是我的xml文件里面并没有任何的注释啊?
我也尝试过在xml的文件里面添加jdbcType,如:
VALUES (#{pkEmailInfoId,jdbcType=BIGINT})
(这里有个需要注意的地方,就是如果jdbcType指定的类型不是jdbc的类型的话,在运行的时候回直接退出,Process finished with exit code 0, 没有任何报错,如果你们在开发过程中遇到这个问题的话,不妨考虑一下是不是mapper中出现了问题)
最后,我在mapper.java的接口文件中,我把映射函数的返回类型把void改成了int,运行成功了???
修改前:
void createInfo(MailClass mailClass);
修改后:
int createInfo(MailClass mailClass);