Bush_nanjing
xiaoke_code
2017-03-24 08:37

mybatis出现了很奇怪的问题

1
  • mybatis
 ### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'card_id' in 'field list'
### The error may exist in com/ershou/mapper/UserMapper.xml
### The error may involve com.ershou.mapper.UserMapper.selectByExample-Inline
### The error occurred while setting parameters
### SQL: select                 card_id, password, college, grade, sex, status, trueName, image         from user                    WHERE (  card_id = ?                                                                             and password = ? )
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'card_id' in 'field list'
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'card_id' in 'field list'] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'card_id' in 'field list'

提示我的card_id 数据库不认识,但是我的数据库就是这样定义的啊
我用的也是generator自动生成的代码
CREATE TABLE user (
card_id varchar(20) NOT NULL,
password varchar(20) DEFAULT NULL,
college varchar(200) DEFAULT NULL,
grade varchar(200) DEFAULT NULL,
sex int(2) DEFAULT '1',
status int(2) DEFAULT '1',
trueName varchar(20) DEFAULT NULL,
image varchar(50) DEFAULT NULL,
PRIMARY KEY (card_id)
)

看一下mybatis的XXXMapper.xml文件










<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.ershou.entity.UserExample" >
select
<if test="distinct" >
  distinct
</if>
<include refid="Base_Column_List" />
from user
<if test="_parameter != null" >
  <include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
  order by ${orderByClause}
</if>

哪里出错了  见鬼了  求大神
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

6条回答