mybatis中的映射关系

时间:2024-10-30 05:02:22

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中的映射关系
© 手抄报圈