MyBatis 延迟加载配置无效,求解,感谢!!
代码如下:<settings>
<!-- 映射下划线到驼峰命名 -->
<setting name="mapUnderscoreToCamelCase" value="true"/>
<!-- 开启延迟加载 -->
<setting name="lazyLoadingEnabled" value="true"/>
<!-- 配置按需加载 -->
<setting name="aggressiveLazyLoading" value="false"/>
<setting name="lazyLoadTriggerMethods" value="toString()"/>
</settings>
@Test
public void testResultMapCascade() throws Exception{
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
SqlSession session = sqlSessionFactory.openSession();
try {
EmployeeMapperResultMap mapper = session.getMapper(EmployeeMapperResultMap.class);
Employee employee = mapper.getEmpAndDeptByIdStep(1001);
System.out.println(employee);
System.out.println(employee.getDepartment());
} finally {
session.close();
}
}
各种方法都试了《要枯了。。。。。。