跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 为什么全局懒加载没有生效呢?
未分類
29 12 月 2020

为什么全局懒加载没有生效呢?

为什么全局懒加载没有生效呢?

資深大佬 : IvanBlade 8

article

public class Article {      private Integer id;      private String title;      private String content;      // 表示当前文章代表的评论列表     private List<Comment> commentList;       @Override     public String toString() {         return "Article{" +                 "id=" + id +                 ", title='" + title + ''' +                 ", content='" + content + ''' +                 ", commentList=" + commentList +                 '}';     }      public String getContent() {         return content;     }      public void setContent(String content) {         this.content = content;     }      public List<Comment> getCommentList() {         return commentList;     }      public void setCommentList(List<Comment> commentList) {         this.commentList = commentList;     }      public Integer getId() {         return id;     }      public void setId(Integer id) {         this.id = id;     }      public String getTitle() {         return title;     }      public void setTitle(String title) {         this.title = title;     }  }  

mapper

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  <mapper namespace="com.Ivan.mapper.ArticleMapper">       <!--一对多关联查询:查询所有的用户,同时还要查询出每个用户所关联的订单信息-->      <resultMap id="articleMap" type="com.Ivan.domain.Article">         <id property="id" column="id"></id>         <result property="title" column="title"></result>         <result property="content" column="content"></result>           <!--             collection : 一对多使用 collection 标签进行关联         -->         <collection property="commentList" ofType="com.Ivan.domain.Comment" fetchType="lazy">             <id property="id" column="cid"></id>             <result property="content" column="content"/>             <result property="author" column="author"/>             <result property="a_id" column="a_id" />         </collection>     </resultMap>       <select id="displayAllArticle"  resultMap="articleMap">         SELECT a.*,c.id cid,c.content, c.author,c.a_id FROM t_comment c RIGHT JOIN t_article a ON c.a_id = a.id     </select>  </mapper> 

部分 sqlmapConfig

<settings>         <!--开启全局延迟加载功能-->          <setting name="lazyLoadingEnabled" value="true"/>         <!--所有方法都会延迟加载-->         <setting name="lazyLoadTriggerMethods" value="toString()"/>          <!--        因为 cacheEnabled 的取值默认就为 true,所以这一步可以省略不配置。        为 true 代表开启二级缓存;为 false 代表不开启二级缓存。    -->         <setting name="cacheEnabled" value="false"/>      </settings>  

结果中的 commentList 还是照常显示。。。是哪里出了问题?

大佬有話說 (0)

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具