• <bdo id='Ujwek'></bdo><ul id='Ujwek'></ul>

      <small id='Ujwek'></small><noframes id='Ujwek'>

      <tfoot id='Ujwek'></tfoot>

      1. <i id='Ujwek'><tr id='Ujwek'><dt id='Ujwek'><q id='Ujwek'><span id='Ujwek'><b id='Ujwek'><form id='Ujwek'><ins id='Ujwek'></ins><ul id='Ujwek'></ul><sub id='Ujwek'></sub></form><legend id='Ujwek'></legend><bdo id='Ujwek'><pre id='Ujwek'><center id='Ujwek'></center></pre></bdo></b><th id='Ujwek'></th></span></q></dt></tr></i><div id='Ujwek'><tfoot id='Ujwek'></tfoot><dl id='Ujwek'><fieldset id='Ujwek'></fieldset></dl></div>
        <legend id='Ujwek'><style id='Ujwek'><dir id='Ujwek'><q id='Ujwek'></q></dir></style></legend>

      2. 如何在 spring-data 中强制使用 CrudRepository 进行预加载?

        How to force eager loading with CrudRepository in spring-data?(如何在 spring-data 中强制使用 CrudRepository 进行预加载?)
      3. <tfoot id='VylsD'></tfoot>
          <tbody id='VylsD'></tbody>
        <legend id='VylsD'><style id='VylsD'><dir id='VylsD'><q id='VylsD'></q></dir></style></legend>

              <bdo id='VylsD'></bdo><ul id='VylsD'></ul>
            • <i id='VylsD'><tr id='VylsD'><dt id='VylsD'><q id='VylsD'><span id='VylsD'><b id='VylsD'><form id='VylsD'><ins id='VylsD'></ins><ul id='VylsD'></ul><sub id='VylsD'></sub></form><legend id='VylsD'></legend><bdo id='VylsD'><pre id='VylsD'><center id='VylsD'></center></pre></bdo></b><th id='VylsD'></th></span></q></dt></tr></i><div id='VylsD'><tfoot id='VylsD'></tfoot><dl id='VylsD'><fieldset id='VylsD'></fieldset></dl></div>

            • <small id='VylsD'></small><noframes id='VylsD'>

                • 本文介绍了如何在 spring-data 中强制使用 CrudRepository 进行预加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含 List 的实体,因此默认加载 lazy:

                  I have an entity containing a List that is thus lazy loaded by default:

                  interface MyEntityRepository extends CrudRepository<MyEntity, Long> {
                  
                  }
                  
                  @Entity
                  public class MyEntity {
                      @Id
                      private Long id;
                  
                      @OneToMany(mappedBy = "bar") //lazy by default
                      private List<Bar> bars;
                  }
                  
                  @Entity
                  public class Bar {
                      //some more
                  }
                  

                  问题:如何在执行 repository.findOne(id) 时强制预先加载?

                  Question: How can I force eager loading when executing repository.findOne(id)?

                  推荐答案

                  我也需要这个,因为我在一个事务内的服务对象中调用 dao,所以我调用了 get 方法,所以没有例外,我是能够获取记录.类似于 java 8 中的东西:

                  I needed this too and as I'm calling the dao inside a service object that is insise a transaction I call call the get method so no exception and I was able to fetch the records. Something like in java 8:

                  public ProductEntity findProduct(int id) {
                      ProductEntity p = productRepository.findOne(id);
                      p.getPresentations().stream().count();
                      return p;
                  }
                  

                  p.getPresentations().stream().count(); 将强制提取,我知道这不是一个干净的方法,但它可以同时完成工作

                  p.getPresentations().stream().count(); will force the fetch, I know is not a clean way to do it but it gets the job done in the mean time

                  这篇关于如何在 spring-data 中强制使用 CrudRepository 进行预加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                      <bdo id='c2CKU'></bdo><ul id='c2CKU'></ul>
                    • <i id='c2CKU'><tr id='c2CKU'><dt id='c2CKU'><q id='c2CKU'><span id='c2CKU'><b id='c2CKU'><form id='c2CKU'><ins id='c2CKU'></ins><ul id='c2CKU'></ul><sub id='c2CKU'></sub></form><legend id='c2CKU'></legend><bdo id='c2CKU'><pre id='c2CKU'><center id='c2CKU'></center></pre></bdo></b><th id='c2CKU'></th></span></q></dt></tr></i><div id='c2CKU'><tfoot id='c2CKU'></tfoot><dl id='c2CKU'><fieldset id='c2CKU'></fieldset></dl></div>

                      <small id='c2CKU'></small><noframes id='c2CKU'>

                            <tbody id='c2CKU'></tbody>

                          <legend id='c2CKU'><style id='c2CKU'><dir id='c2CKU'><q id='c2CKU'></q></dir></style></legend>
                        1. <tfoot id='c2CKU'></tfoot>