1
我嘗試以下,如果從句中的MyBatis並得到了以下異常,請幫我找出這裏的問題..MyBatis的if語句
public class Student{
private Integer studId;
private String name;
private String email;
private Date dob;
}
映射
例外,我得到:
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test="studId != null">
AND STUD_ID= 1
</if>
<if test="name != null">
' at line 4
### The error may exist in StudentMapper.xml
### The error may involve com.maventest.mytest.StudentMapper.searchStudent-Inline
### The error occurred while setting parameters
### SQL: SELECT * FROM STUDENTS WHERE 1 = 1 <if test="studId != null"> AND STUD_ID= ? </if> <if test="name != null"> AND NAME like ? </if>
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test="studId != null">
AND STUD_ID= 1
</if>
<if test="name != null">
' at line 4
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)