<tfoot id='xwo49'></tfoot>
  • <small id='xwo49'></small><noframes id='xwo49'>

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

        <legend id='xwo49'><style id='xwo49'><dir id='xwo49'><q id='xwo49'></q></dir></style></legend>
          <bdo id='xwo49'></bdo><ul id='xwo49'></ul>

        在 Spring Data MongoDB 存储库中计数

        Count in Spring Data MongoDB repository(在 Spring Data MongoDB 存储库中计数)

            <tbody id='kkTGS'></tbody>

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

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

                • 本文介绍了在 Spring Data MongoDB 存储库中计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道是否有任何机制可以在 Spring Data MongoDB 存储库中使用 count@Query 注释?我很想收到我所拥有的文件数量,而不必获取所有文件.

                  I wonder if there's any mechanism to use count in Spring Data MongoDB repository with @Query annotation? I would love to receive the number of documents that I have without having to get all of them.

                  基本上相当于Java中的this:

                  Basically, the equivalent of this in Java:

                  db.test.find({"type":"foo"}).count 
                  

                  推荐答案

                  对我来说,这个解决方案就像一个魅力(使用 spring-data-mongodb 1.3.1.RELEASE ),我刚刚遇到了同样的问题并像这样解决了它(只是我工作代码中的一小段):

                  For me this solutions works like a charm( using spring-data-mongodb 1.3.1.RELEASE ), I just had the same problem atm and solved it like this(just a short snippet from my code at work):

                  @Query(value = "{'productDetails.productType': {$regex: ?0, $options: 'i'}, 'sourceDescriptor': ?1}", count = true)
                  public Long countFetchedDocumentsForCategory(String cat, String sourceDescriptor);
                  

                  这篇关于在 Spring Data MongoDB 存储库中计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 中的默认语言环境设置以使其保持一致?)

                    1. <small id='O7k7p'></small><noframes id='O7k7p'>

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

                        <tbody id='O7k7p'></tbody>
                        <legend id='O7k7p'><style id='O7k7p'><dir id='O7k7p'><q id='O7k7p'></q></dir></style></legend>
                            <bdo id='O7k7p'></bdo><ul id='O7k7p'></ul>