org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred while applying a parameter map. --- Check the fruitUser.selectByCriteria-InlineParameterMap. --- Check the statement (query failed). --- Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'user' 附近有语法错误。
这个错误是我操作数据库表时出的问题:
<select id="selectByCriteria" parameterClass="fruitLog"
resultMap="baseResultMap">
select
id,
username, <!-- 主键ID -->
password,
mobil_telephone_number,
email,
detail_address,
name,
no_of_IDcertificate,
lastLogIp,
lastLogTime,
info
from user
<include refid="fruitUser.criteria_Where_Clause" />
</select>
把查询语句修改成如下的方式就可以了
<select id="selectByCriteria" parameterClass="fruitLog"
resultMap="baseResultMap">
select
id,
username, <!-- 主键ID -->
password,
mobil_telephone_number,
email,
detail_address,
name,
no_of_IDcertificate,
lastLogIp,
lastLogTime,
info
from [user]
<include refid="fruitUser.criteria_Where_Clause" />
</select>
问题原因是表明和数据库的关键字重复导致的问题