實體類java
@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方法spring
@Override public AppGroupUser selectByPrimaryKey(String appGroupUserId) { return super.selectByPrimaryKey(appGroupUserId); }
錯誤信息sql
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的,爲啥是所有條件查詢???express
說明mybatis並不知道按照id去查詢數據,而是按照全部條件去查詢,難怪查詢全部queryList()時能查到數據。因此咱們須要指定id爲主鍵才能夠。apache