首页 > TAG信息列表 > selectByPrimaryKey

springboot service 用 @Autowired注入 mapper 为null

Service类 @Controller public class AdminRoleService { @Autowired AdminRoleMapper adminRoleMapper; public AdminRole selectByPrimaryKey(Integer roleId) { AdminRole adminRole = adminRoleMapper.selectByPrimaryKey(10001); return a

Mybatis报错ClassCastException: java.lang.String cannot be cast to java.util.Date

Mybatis报错: 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,

Mybatis缓存及注意点

mybatis分为两级缓存 一级缓存 一级缓存是SqlSession级别的缓存。在操作数据库时需要构造sqlSession对象,在对象中有一个数据结构(HashMap)用于存储缓存数据。不同的sqlSession之间的缓存数据区域(HashMap)是互相不影响的。 一级缓存是默认开启的不用配置。 @Autowired private Sq

使用TK框架中selectByPrimaryKey

使用TK框架中selectByPrimaryKey(Object key),需要注意要在entity里注明哪个字段是主键,否则会不知道哪个是PrimaryKey会随机一个字段就报错。      如下: 引入 import javax.persistence.Id; /** * 主键ID */@Idprotected String id;    

Invalid bound statement (not found): cn.e3mall.mapper.TbItemMapper.selectByPrimaryKey

此异常的原因是由于mapper接口编译后在同一个目录下没有找到mapper映射文件而出现的。由于maven工程在默认情况下src/main/java目录下的mapper文件是不发布到target目录下的。 在e3-manager-dao工程的pom文件中添加如下内容: <!-- 如果不添加此节点mybatis的mapper.xml文件都会