博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Mybatis之ResultMap映射
阅读量:6359 次
发布时间:2019-06-23

本文共 5223 字,大约阅读时间需要 17 分钟。

准备如下用户表,订单表,订单明细表,商品表

用户表:user_id,user_name

订单表:order_id,order_no,user_id

订单明细表:orderdetail_id,order_id,product_id

商品表:product_id,product_name

 

实体类

package com.zns.domain;import java.util.List;public class User {    private int userid;    private String username;    private List
orders; public int getUserid() { return userid; } public void setUserid(int userid) { this.userid = userid; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public List
getOrders() { return orders; } public void setOrders(List
orders) { this.orders = orders; } @Override public String toString() { return "User [userid=" + userid + ", username=" + username + ", orders=" + orders + "]"; }}

 

package com.zns.domain;import java.util.List;public class Order {    private int orderid;    private String orderno;    private int userid;    private User user;    private List
orderDetails; public int getOrderid() { return orderid; } public void setOrderid(int orderid) { this.orderid = orderid; } public String getOrderno() { return orderno; } public void setOrderno(String orderno) { this.orderno = orderno; } public int getUserid() { return userid; } public void setUserid(int userid) { this.userid = userid; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public List
getOrderDetails() { return orderDetails; } public void setOrderDetails(List
orderDetails) { this.orderDetails = orderDetails; } @Override public String toString() { return "Order [orderid=" + orderid + ", orderno=" + orderno + ", userid=" + userid + ", user=" + user + ", orderDetails=" + orderDetails + "]"; }}

 

package com.zns.domain;public class OrderDetail {    private int orderdetailid;    private int orderid;    private int productid;    private Product product;    public int getOrderdetailid() {        return orderdetailid;    }    public void setOrderdetailid(int orderdetailid) {        this.orderdetailid = orderdetailid;    }    public int getOrderid() {        return orderid;    }    public void setOrderid(int orderid) {        this.orderid = orderid;    }    public int getProductid() {        return productid;    }    public void setProductid(int productid) {        this.productid = productid;    }    public Product getProduct() {        return product;    }    public void setProduct(Product product) {        this.product = product;    }    @Override    public String toString() {        return "OrderDetail [orderdetailid=" + orderdetailid + ", orderid=" + orderid + ", productid=" + productid                + ", product=" + product + "]";    }}

 

package com.zns.domain;public class Product {    private int productid;    private String productname;    public int getProductid() {        return productid;    }    public void setProductid(int productid) {        this.productid = productid;    }    public String getProductname() {        return productname;    }    public void setProductname(String productname) {        this.productname = productname;    }    @Override    public String toString() {        return "Product [productid=" + productid + ", productname=" + productname + "]";    }}

 

 

Mybatis映射配置如下

 

转载于:https://www.cnblogs.com/zengnansheng/p/10389261.html

你可能感兴趣的文章
IE FF(火狐) line-height兼容详解
查看>>
TX Text Control文字处理教程(3)打印操作
查看>>
mysqld_multi实现多主一从复制
查看>>
中介模式
查看>>
JS中将变量转为字符串
查看>>
servlet笔记
查看>>
JVM(五)垃圾回收器的前世今生
查看>>
Spring Boot 自动配置之@EnableAutoConfiguration
查看>>
web前端笔记
查看>>
finally知识讲解
查看>>
Matplotlib绘图与可视化
查看>>
openstack ocata版(脚本)控制节点安装
查看>>
【微信公众号开发】获取并保存access_token、jsapi_ticket票据(可用于微信分享、语音识别等等)...
查看>>
datatable 获取最大值
查看>>
sqlserver2012一直显示正在还原(Restoring)和从单用户转换成多用户模式(单用户连接中)...
查看>>
spark复习总结02
查看>>
李瑞红201771010111《第九周学习总结》
查看>>
pymongo模块
查看>>
第0次作业
查看>>
快排+折半查找
查看>>