<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] # 什么是延遲加載 在真正使用的時候才發起查詢,不用的時候不發起,按需加載. 還有是不管用不用,立即加載 一對多,多對多,通常是延遲加載 多對一,一對一,通常是立即加載 # 開啟延遲加載 * lazyLoadingEnabled: 延遲加載的全局開關.當開啟時,所有關聯對象都會延遲加載.特定關聯關系可以通過設置fetchType屬性來覆蓋該選項的開關狀態 * aggressiveLazyLoading: 當開啟時,任何方法的調用都會加載該對象的所有屬性.否則,每個屬性都會按需加載(參考lazyLoadTriggerMethods) 我們要在mybatis的SqlMapConfig.xml文件中添加延遲加載的配置 configuration標簽下 ~~~ <!-- 開啟延遲加載的支持 --> <settings> <setting name="lazyLoadingEnabled" value="true" /> <setting name="aggressiveLazyLoading" value="false" /> <!-- lazyLoadTriggerMethods:指定哪個對象的方法觸發一次延遲加載。 默認值:equals,clone,hashCode,toString,可以阻擋不相干的操作觸發,實現懶加載 --> <setting name="lazyLoadTriggerMethods" value="" /> </settings> ~~~ # assocation實現一對一延遲 接口 ~~~ <!-- 建立起對應關系 --> <resultMap id="accountMap" type="com.jdxia.domain.Account"> <id column="id" property="id" /> <result column="uid" property="uid" /> <result column="money" property="money" /> <!-- 關聯的屬性 --> <!-- select我們要填調用的select映射的全限定id, column我們要寫傳遞給select映射的參數 --> <association property="user" javaType="com.jdxia.domain.User" select="com.jdxia.dao.IUserDao.findById" column="uid" /> </resultMap> <select id="findAll" resultMap="accountMap"> select * from account </select> ~~~ 執行 ~~~ List<Account> accountDaoAll = accountDao.findAll(); ~~~ 查看sql執行幾次 ps: toString的話要看你有沒有配置lazyLoadTriggerMethods這個了 # Collection實現一對多延遲 Collection結點中也有 select 屬性,column 屬性 ~~~ <!-- 建立起對應關系 --> <resultMap id="accountMap" type="com.jdxia.domain.Account"> <id column="id" property="id" /> <result column="uid" property="uid" /> <result column="money" property="money" /> <!-- 關聯的屬性 --> <!-- select我們要填調用的select映射的全限定id, column我們要寫傳遞給select映射的參數 --> <Collection property="user" javaType="com.jdxia.domain.User" select="com.jdxia.dao.IUserDao.findById" column="uid" /> </resultMap> <select id="findAll" resultMap="accountMap"> select * from account </select> ~~~ # 多列值封裝map傳遞 分步查詢的時候通過column指定,將對應的列的數據 傳遞過去,我們有時需要傳遞多列數據。 使用`{key1=column1,key2=column2...}`的形式 key1就是你Collection里面select哪個id中的`#{}` column1代表你要從這取的值 # 不想延遲加載 在Mybatis核心配制文件中配制延遲加載后全對所有滿足延遲加載的SQL進行延遲加載操作。 當某條SQL滿足延遲加載條件,但又不想讓其延遲加載時可以使用fetchType屬性進行控制。 默認情況下fetchType的值為true,表示支持延遲加載,將fetchType值改為false即可取消延遲加載。 ~~~xml <select id="getClassAndStudentByClassID" resultMap="classAndStudentMap"> SELECT class_name, class_code FROM class WHERE class_id = #{class_id} </select> <resultMap id="classAndStudentMap" type="com.cat.pojo.ClassInfo"> <result column="class_code" property="classCode" /> <result column="class_name" property="className" /> <assosiation property="class_code" select="com.cat.mapper.StudentMapper.getStudentsByClassId" fetchType="false" /> </resultMap> ~~~ fetchType屬性同樣可以作用于collection標簽。 `fetchType=eager/lazy`中eager立即加載,lazy延遲加載
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看