[Mybatis] 注解操作

  • 查询数据库返回时,将数据库字段与实体类属性进行对应(主要用于多表关联)

@Select("select * from order")
    @Results({
            @Result(id=true,property = "id",column = "id"),   // 设置主键, property = "实体类属性名", column = "数据字段名"
            @Result(property = "orderNum", column = "orderNum"),
            @Result(property = "product", column = "productId", javaType = Product.class, one = @One(select = "dao包名.IProductDao.findById")) 
    })
    public List<Orders> findAll() throws Exception;

猜你喜欢

转载自www.cnblogs.com/fydra/p/12770525.html