实体类
@Data
public class AppGroupUser extends AppBaseEntity {
private static final long serialVersionUID = 1L;
/**
* 群组用户关系ID
*/
private String groupUserId;
/**
* 群组ID
*/
private String groupId;
/**
* 用户ID
*/
private String userId;
/**
* 群昵称
*/
private String userNickName;
/**
* 用户等级 0-普通用户 1-管理员 2-群主
*/
private String userRank;
/**
* 邀请入群用户id
*/
private String entryUserId;
/**
* 进群方式
*/
private String entryType;
/**
* 禁言 0-未禁言 1-已禁言
*/
private String sayStatus;
}
Service方法
@Override
public AppGroupUser selectByPrimaryKey(String appGroupUserId) {
return super.selectByPrimaryKey(appGroupUserId);
}
错误信息
16:50:05.487 [main] DEBUG c.r.s.m.A.selectByPrimaryKey - [debug,159] - ==> Preparing: SELECT create_time,creator,update_time,updater,del_flag,group_user_id,group_id,user_id,user_nick_name,user_rank,entry_user_id,entry_type,say_status FROM app_group_user WHERE create_time = ? AND creator = ? AND update_time = ? AND updater = ? AND del_flag = ? AND group_user_id = ? AND group_id = ? AND user_id = ? AND user_nick_name = ? AND user_rank = ? AND entry_user_id = ? AND entry_type = ? AND say_status = ?
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='createTime', 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.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
我明明是通过主键ID 去查询sql的,为啥是全部条件查询???
说明mybatis并不知道按照id去查询数据,而是按照所有条件去查询,难怪查询所有queryList()时能查到数据。所以我们需要指定id为主键才可以。