搜索

008.多表关联查询---ResultMap结果映射(DTO:数据传输对象)把复杂查询的对象映射为DTO对象


发布时间: 2022-11-24 23:49:00    浏览次数:69 次

1.ResultMap结果映射

 

 2.利用java对象保存保存多表关联结果

2.1  创建GoodsDTOd.java,用于对原始数据进行扩展,用于数据保存和传递(src/main/java/com/imooc/mybatis/dto)

 

 

2.2 goods.xml

2.3  测试类

 

 2.4 对上述案列进行扩展

2.4.1 创建entity实体类Category.java

package com.imooc.mybatis.entity;

public class Category {
    private Integer categoryId;
    private String categoryName;
    private Integer parentId;
    private Integer categoryLevel;
    private Integer categoryOrder;

    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Integer categoryId) {
        this.categoryId = categoryId;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Integer getCategoryLevel() {
        return categoryLevel;
    }

    public void setCategoryLevel(Integer categoryLevel) {
        this.categoryLevel = categoryLevel;
    }

    public Integer getCategoryOrder() {
        return categoryOrder;
    }

    public void setCategoryOrder(Integer categoryOrder) {
        this.categoryOrder = categoryOrder;
    }
}

2.4.2创建GoodsDTOd.java,用于对原始数据进行扩展,用于数据保存和传递(src/main/java/com/imooc/mybatis/dto)

package com.imooc.mybatis.dto;

import com.imooc.mybatis.entity.Category;
import com.imooc.mybatis.entity.Goods;

//Data Transfer Object--数据传输对象
public class GoodsDTO {
    private Goods goods = new Goods();
    private Category category = new Category();
    private String test;

    public Goods getGoods() {
        return goods;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public String getTest() {
        return test;
    }

    public void setTest(String test) {
        this.test = test;
    }
}

2.4.3 测试类

 

免责声明 008.多表关联查询---ResultMap结果映射(DTO:数据传输对象)把复杂查询的对象映射为DTO对象,资源类别:文本, 浏览次数:69 次, 文件大小:-- , 由本站蜘蛛搜索收录2022-11-24 11:49:00。此页面由程序自动采集,只作交流和学习使用,本站不储存任何资源文件,如有侵权内容请联系我们举报删除, 感谢您对本站的支持。 原文链接:https://www.cnblogs.com/LLL0617/p/16923874.html