mybatis(xml方式)五表查询

下载项https://github.com/

https://gitee.com/

一,添加依赖

二创建pojo

User.java
Order.java


Detail.java
Product.java
Type.java

三创建一个db.properties文件,将连接信息放进去,并且创建mybatis.xml文件

mybatis.xml

四创建一些mapper.xml文件

usermapper.xml
ordermapper.xml
detailmapper.xml  
productmapper.xml    
typemapper.xml 

五测试

结果如下
User{uid=1, name='孙悟空', password='孙悟空', phone='111', orders=[Order{oid=1, price=10000.0, addr='安徽合肥', payType='支付宝', uid=1, details=[Detail{did=1, count=1, pid=2, oid=1, product=Product{pid=2, name='华为mate30', img='https://img.alicdn.com/bao/uploaded/i3/2838892713/O1CN01iQsgbV1Vub5P7ZuVf_!!2838892713.png', price=6399.0, type=Type{tid=1, name='手机'}}}, Detail{did=2, count=1, pid=1, oid=1, product=Product{pid=1, name='iphone11', img='https://img.alicdn.com/bao/uploaded/i1/1917047079/O1CN01wmhZr022AEJB9610K_!!2-item_pic.png', price=5999.0, type=Type{tid=1, name='手机'}}}]}, Order{oid=2, price=2000.0, addr='江苏南京', payType='微信', uid=1, details=[]}]}

2020-3-11

你可能感兴趣的:(mybatis(xml方式)五表查询)