Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.5
    • Fix Version/s: 2.1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Ubuntu

      Description

      Hi, i get this error message when executing a query with INSTANCE OF.
      Notice: Undefined index: \model\PeopleTaskRecommendFriends in /usr/share/php/Doctrine/ORM/Query/SqlWalker.php on line 1626

      The query to be executed is this:

                      $query = $this->_em->createQuery("SELECT pt
                                                FROM \model\PeopleTask pt
                                                WHERE pt instance of \model\PeopleTaskRecommendFriends
                                                ");
      

      The query actually being executed is this:

      SELECT t0_.int_people_task_id AS int_people_task_id0, t0_.int_people_id AS int_people_id1, t0_.dtm_creation AS dtm_creation2, t0_.bit_completed AS bit_completed3, t0_.vch_names AS vch_names4, t0_.int_task_type_id AS int_task_type_id5 FROM tbl_xref_people_task t0_ WHERE (t0_.int_task_type_id = '') AND t0_.int_task_type_id IN ('1', '2')
      

      The first problem is that for some reason its translating the query with a wrong where clause, so of course no data is returned.

      Here is the model

      ------------------------------------------ Base class----------------------------------------
      /**
       * @Entity(repositoryClass="repository\PeopleTaskRepository")
       * @InheritanceType("SINGLE_TABLE")
       * @DiscriminatorColumn(name="int_task_type_id", type="integer")
       * @DiscriminatorMap({1 = "PeopleTaskRecommendFriends", 2 = "PeopleTaskAddBadge"})
       * @Table(name="tbl_xref_people_task")
       */
      abstract class PeopleTask extends BaseModel {
       
          /**
           * @Id
           * @GeneratedValue
           * @Column(type="integer") */
          protected $int_people_task_id;
       
          /** @Column(type="integer") */
          protected $int_people_id;
       
          /** @Column(type="datetime") */
          protected $dtm_creation;
       
          /** @Column(type="bit")*/
          protected $bit_completed;
       
          /** @Column(length=255) */
          protected $vch_names;
       
      }
       
      ----------------------------------------------------Children class-----------------------------------------------
       
      /**
       * @Entity(repositoryClass="repository\peopleTask\PeopleTaskRecommendFriendsRepository")
       */
      class PeopleTaskRecommendFriends extends PeopleTask {
       /* some methods */
       
      }
       

        Activity

        Hide
        Benjamin Eberlei added a comment -

        A fix for this is probably just ommitting the prefix \ infront of the model in the DQL. Class Names in Strings are ALWAYS fully qualified, therefore the leading slash has to be omitted.

        Show
        Benjamin Eberlei added a comment - A fix for this is probably just ommitting the prefix \ infront of the model in the DQL. Class Names in Strings are ALWAYS fully qualified, therefore the leading slash has to be omitted.
        Hide
        Benjamin Eberlei added a comment -

        Improved error handling when in "a INSTANCE OF b" the classes a and b are unrelated.

        Show
        Benjamin Eberlei added a comment - Improved error handling when in "a INSTANCE OF b" the classes a and b are unrelated.
        Hide
        Hernan Rajchert added a comment -

        Thanks, that did solve my problem.

        On a related note, for the original query i had to do this:
        $qb->andWhere('pt INSTANCE OF '.$task_type);
        instead of this
        $qb->andWhere('pt INSTANCE OF :taskType');
        $qb->setParameter('taskType', $task_type);

        because it complains about the parameter not being a metadata type, and i couldnt find a way to get the metadata type.

        Show
        Hernan Rajchert added a comment - Thanks, that did solve my problem. On a related note, for the original query i had to do this: $qb->andWhere('pt INSTANCE OF '.$task_type); instead of this $qb->andWhere('pt INSTANCE OF :taskType'); $qb->setParameter('taskType', $task_type); because it complains about the parameter not being a metadata type, and i couldnt find a way to get the metadata type.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Hernan Rajchert
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: