mybatis 一对多,嵌套查询
来源:互联网 发布:如涵贸易有哪些淘宝店 编辑:程序博客网 时间:2024/05/16 19:42
商品表product
图片表productImage
一个商品包含多张图片
productMapper:
<select id="getAllProduct" resultMap="getAllProductMap">
SELECT * from product
a,producttype t where
a.productTypeId = t.productTypeId and a.producttypeid=#{producttypeid}
limit #{pageIndex},#{pageSize}
</select>
<resultMap type="com.chinasoft.model.entity.Product" id="getAllProductMap"
extends="BaseResultMap">
<association property="productType"
javaType="com.chinasoft.model.entity.ProductType">
<id property="producttypeid" column="producttypeid"></id>
<result property="producttypename" column="producttypename"></result>
<result property="producttypeinfo" column="producttypeinfo"></result>
</association>
<collection property="productImageList"
ofType="com.chinasoft.model.entity.ProductImage"
column="productid"
select="com.chinasoft.model.dao.ProductImageMapper.getImage">
<id property="productimageid" column="productimageid"></id>
<result property="productimageaddress" column="productimageaddress"></result>
<result property="productid" column="productid"></result>
<result property="productimageinfo" column="productimageinfo"></result>
</collection>
</resultMap>
productImageMapper:
<select id="getImage" resultType="com.chinasoft.model.entity.ProductImage" parameterType="Integer">
select * from ProductImage where productid = #{productid}
</select>
商品表实体
private Integer productid;
private Integer producttypeid;
private String productname;
private String productnumber;
private String productinfo;
private String producttime;
private Long productprice;
private Integer productcount;
// 一对多,加入商品对应的图片集
private List<ProductImage> productImageList;
- mybatis 嵌套查询,一对多
- mybatis 一对多,嵌套查询
- Mybatis各种查询,一对一,一对多,嵌套
- 使用MyBatis(九)一对多的集合的嵌套查询
- mybatis一对多查询
- mybatis一对多查询
- Mybatis一对多查询
- Mybatis 一对多 查询
- mybatis 一对多查询
- Mybatis 一对多 查询
- Mybatis一对多查询
- Mybatis一对多查询
- Mybatis(一对多查询)
- MyBatis实现关联表查询(一对一,一对多,联合查询,嵌套查询)
- mybatis“集合嵌套查询”和“集合嵌套结果”两种方法实现数据库一对多关系
- mybatis“集合嵌套查询”和“集合嵌套结果”两种方法实现数据库一对多关系
- mybatis“集合嵌套查询”和“集合嵌套结果”两种方法实现数据库一对多关系
- mybatis一对多查询配置
- 解决服务器自动死机的问题
- NOIP2016普及组复赛解题报告
- 深入研究PHP及Zend Engine的线程安全模型
- JXL compare with POI
- poj3268 -- Silver Cow Party
- mybatis 一对多,嵌套查询
- (POJ1080)Human Gene Functions <DP,最长公共子序列变形>
- 【OI做题记录】【BZOJ】【Ahoi2014】骑士游戏
- MPAndroidChart详解
- Android中电话监听并删除来电记录
- log4j详细配置
- IntelliJ Idea 常用快捷键列表
- CodeForces 723D-Lakes in Berland(BFS DFS)
- ctf IDF实验室摩斯密码