To perform any Create, Retrieve, Update, and Delete (CRUD) operation using MyBatis, you would need to create a Plain Old Java Objects (POJO) class corresponding to the table. This class describes the objects that will “model” database table rows.
要使用MyBatis执行任何创建、读取、更新和删除(CRUD)操作,您需要创建与该表相对应的普通旧Java对象(POJO)类。此类描述了将“建模”数据库表行的对象。
在UserMapper.xml 的配置文件中,<mapper namespace="net.hw.mybatis.mapper.UserMapper">
,命名空间非常重要,不能有错,必须与我们定义的package和接口一致。
一、打开MyBatisDemo项目
二、查询表记录
- 上一讲,我们在UserMapper.xml里定义了两个查询语句:findById和findAll,对应