标签:配置 source int app 实体类 integer 数据表 mamicode private
类的名字,必须
1、与数据库中表的名字对应
2、遵守标准,首字母大写,虽然数据库中不分大小写
类具有的属性
1、实体类的类名与数据表的表名一样(数据库中不区分大小写,Java中区分大小写,以后都采用大头峰,也就是每个单词的首字母都大写)
2、实体类的属性要与数据表的字段对应(名字一样;类型匹配)(int最好使用Integer,因为int类型不能表示null)
3、符合JavaBean规则
4、实体类必须提供无参构造方法(如果一个类中添加了有参构造方法,就应该显式声明无参构造方法)
100%对应
(一)Mapper接口
1、@Mapper
2、根据用户需求机型函数参数的设置,参数最好与数据库中数据类型匹配
(二)配置文件
1、头部
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2、中间部分
<mapper namespace="com.st.apple.mapper.接口全名"> <select></select> <insert></insert> </mapper> 例如: <mapper namespace="com.st.apple.mapper.UserMapper"> </mapper>
三、
标签:配置 source int app 实体类 integer 数据表 mamicode private
原文地址:https://www.cnblogs.com/fengguoyulin/p/12150136.html