---
title: "Mybatis延迟加载机制"
author: "J2EE大鸟"
date: "2012-12-08T18:43:49Z"
tags: []
categories: ["行业应用"]
slug: "mybatis"
draft: false
lastmod: "2012-12-08T18:43:49Z"
id: 1744227
url: "https://benworld.iteye.com/blog/1744227"
---

Mybatis延迟加载机制--à 效率蛮高

 

@Test

   **public** **void** testFindById() {

      OrderType ot = **new** OrderType();

      **try** {

        ot = otd.findById(1);

//      System.out.println(ot.getFlowList().size());

      } **catch** (NoSuchRecordException e) {

        e.printStackTrace();

      }

      TimeType tt = **new** TimeType();

      tt.setTtid(1);

     

      Flow f = **new** Flow();

      f.setFlowname("离港港时间");

      f.setOrdertype(ot);

      f.setTimetype(tt);

     

      fd.addFlow(f);

     

      System.*out*.println(ot.getFlowList().size());

//    System.out.println(ot.getOrdertypeid());

//    System.out.println(ot.getOrdertypename());

//    System.out.println(ot.getOrdersList().get(0).getOrderid());

   }

 

在黄色代码段不执行时， 在添加流程后， 通过订单类型的一对多关系可以取到变化后的FlowList对象。 执行了黄色代码后， 则不行。