Mybatis 懒加载

开启懒加载配置

config.xml

    
        
        
        
        
        
        
    

实体bean

BorrowBean

public class BorrowBean {
    private int id;
    private Date date;
    private int num;
    
    // 书籍
    private BookBean book;
    // 用户
    private UserBean user;
    // ... get set 方法
}

BooKBean

public class BookBean {
    private int id;
    private String name;
    private String picture;
    private String author;
    private String press;
    private Date time;
    private int price;
    private int stock;
    private String describe;
    // ... get set 方法
}

UserBean

public class UserBean {
    private int id;
    private String name;
    private String pwd;
    
    // 一个用户借多本图书
    private List booklist;
    // ... get set 方法
}

配置 Mapper.xml

BorrowMapper.xml





    
    
    
        
        
        
        
        
        
        
        
        
    

你可能感兴趣的:(Mybatis 懒加载)