MyBatis映射文件的resultMap如何做表关联
展开全部
MybatiscustomerMapper.xml: select *from MYBATISORDER where ORDERID = #{orderid,jdbcType=DECIMAL} MybatisOrderItemMapper.xml: select *from MYBATISORDERITEMwhere ITEMID = #{itemid,jdbcType=DECIMAL} MybatiscustomerMapper.xml:因为不和别的表做关联,只有简单的id,result配置. select *from MYBATISCUSTOMER where ID = #{id,jdbcType=DECIMAL} MybatisOrderMapper的getOrderByID会先从MYBATISORDER取数据,然后根据CUSTOMERID调用MybatiscustomerMapper.getCustomerByID,然后根据ORDERID调用MybatisOrderItemMapper.selectItemsByOrderID,对应每一条MYBATISORDER数据,都会分别访问另外两个表各一次.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询