Skip to content


DDC-1194: Problem using Instance of feature #1799

doctrinebot opened this Issue · 4 comments

2 participants


Jira issue originally created by user hrajchert:

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 **/


Comment created by @beberlei:

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.


Comment created by @beberlei:

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


Issue was closed with resolution "Fixed"


Comment created by hrajchert:

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.

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.