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

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

        找不到 ID id(155) 的类型为“AppBundleEntityUser"的实体

        时间:2024-08-09

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

            • <bdo id='1U7fP'></bdo><ul id='1U7fP'></ul>

              <small id='1U7fP'></small><noframes id='1U7fP'>

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

                    <tbody id='1U7fP'></tbody>
                • 本文介绍了找不到 ID id(155) 的类型为“AppBundleEntityUser"的实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我遍历一个组的用户(组#users,它是多对一关系)以显示用户电子邮件时,我收到此错误 Entity of type 'AppBundleEntityUser' for IDs id(155)找不到.但是,当我显示引发异常的用户时,我会看到:

                  When I iterate over users of one group (group#users and it's a ManyToOne relationship) to display the users emails, I get this error Entity of type 'AppBundleEntityUser' for IDs id(155) was not found. However, when I display the user for which the exception is raised I see this:

                  // In my controller
                  dump($groups[0]->getUser());
                  
                  // Output
                  User {#761 ▼
                    +__isInitialized__: false
                    #id: 155
                    #email: null
                    #firstName: null
                    #lastName: null
                    #roles: null
                     …2
                  }
                  

                  此外,此用户(其 id 等于 155)确实存在于我的数据库中.

                  Besides, this user (whose id equals 155) does exist in my database.

                  更新 1

                  public function getByCriteria(array $criteria)
                  {
                      $qb = $this->createQueryBuilder('g');
                      // ....
                  
                  
                      return $qb
                              ->getQuery()
                              // This does NOT change anything ?? Isn't this supposed to load related user??
                              // http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#temporarily-change-fetch-mode-in-dql
                              ->setFetchMode('class_namespace', 'user', ClassMetadata::FETCH_EAGER)
                              ->getResult();
                  }
                  

                  推荐答案

                  想通了!!实际上有一个启用的学说过滤器在每个 sql 查询中添加一个条件.当我得到一个组时,与其相关的用户不会从数据库中加载,只有它的 id 与组实体一起加载.当我尝试访问 id 以外的其他用户字段时,它会执行 sql join 查询.同样,学说过滤器将条件添加到连接条件中,这会导致结果为空.

                  Figured it out!! Actually there is a an enabled doctrine filter that adds one condition in every sql query. When I get one group, the user being related to it is not loaded from the database, only its id is loaded with the group entity. When I try to access other user field than the id, it performs the sql join query. Again, the doctrine filter adds the condition even to the join condition, which leads to an empty result.

                  所以错误信息显然具有误导性.

                  So the error message is clearly misleading.

                  这篇关于找不到 ID id(155) 的类型为“AppBundleEntityUser"的实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Doctrine2:不能通过标识变量选择实体而不选择至少一个根实体别名 下一篇:Doctrine Regular vs Fetch join

                  相关文章

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

                  2. <tfoot id='O4aOI'></tfoot>