mybatis中的映射关系

2025-04-27 18:49:14

1、mybatis中使用的代理模式,dao接口与mapper文件的关系,就是代理关系,dao接口内只有方法,而具体的实现依赖mapper文件例如:dao接口内的方法:publicListfindAll();mapper内的实现:

mybatis中的映射关系

2、id对应的是接口内的方法 ,resultType返回值类型,resultMap返回的是集合<select id="findAll" resultMap="profitMap">select p.storePhone,p.number,s.id,s.name,s.price,s.percent from profit p,seed s where p.seedId=s.id;</select><resultMap type="Profit" id="profitMap"><result column="storePhone" property="storePhone"/><result column="number" property="number"/>

mybatis中的映射关系

3、一对一关系对应使用association,property对应实体对象的属性,javatypejava类型,column对应的一对一的一个键值;<association property="seed" javaType="Seed" column="seedId"><id column="id" property="id"/><result column="name" property="name"/><result column="price" property="price"/><result column="percent" property="percent"/></association></resultMap>

mybatis中的映射关系
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢