Search by criteria error vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php line 44 #6771

Closed
opened 2026-01-22 15:38:20 +01:00 by admin · 2 comments
Owner

Originally created by @nyatMeat on GitHub (Jun 29, 2021).

I have an issue
vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php line 44


    /**
     * @param $teamId
     * @return Team|null
     */
    public function getTeamByAccount(Account $account): ?Team
    {
        $criteria = Criteria::create()->where(Criteria::expr()->eq("account", $teamId));

        $collection = $this->getTeams()->matching($criteria);
        if ($collection->isEmpty()) {
            return null;
        }

        return $collection->first();
    }

The code of the Team entity

/**
 * @ORM\Entity(repositoryClass=TeamRepository::class)
 * @ORM\Table(name="team")
 * @ORM\HasLifecycleCallbacks()
 */
class Team
{
    use TimestampableTrait;

    /**
     * @var \Ramsey\Uuid\UuidInterface
     *
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class=UuidGenerator::class)
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $name;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $description;


    /**
     * @ORM\ManyToOne(targetEntity=Account::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $account;
    
    /**
     * @ORM\ManyToOne(targetEntity=User::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $manager;

The code of the Account entity

/**
 * @ORM\Entity(repositoryClass=AccountRepository::class)
 * @ORM\Table(name="account")
 * @ORM\HasLifecycleCallbacks()
 */
class Account
{

    use TimestampableTrait;

    /**
     * @var \Ramsey\Uuid\UuidInterface
     *
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class=UuidGenerator::class)
     */
    private $id;

    /**
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;


    /**
     * @ORM\Column(name="state", type="string", length=255)
     */
    private $state;

And the code of the User entity

class User
{


    use TimestampableTrait;

    /**
     * @var \Ramsey\Uuid\UuidInterface
     *
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class=UuidGenerator::class)
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=180, unique=true)
     */
    private $email;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $firstName = '';

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $lastName = '';

    /**
     * @ORM\ManyToMany(targetEntity=Account::class)
     */
    private $accounts;

    /**
     * @ORM\ManyToMany(targetEntity=Team::class)
     */
    private $teams;

What could be wrong? As I read in articles about using criteria in the Entity everything should be fine, but it doesn't

Could someone help me to understand what the wrong here?

Originally created by @nyatMeat on GitHub (Jun 29, 2021). I have an issue vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php line 44 ```php /** * @param $teamId * @return Team|null */ public function getTeamByAccount(Account $account): ?Team { $criteria = Criteria::create()->where(Criteria::expr()->eq("account", $teamId)); $collection = $this->getTeams()->matching($criteria); if ($collection->isEmpty()) { return null; } return $collection->first(); } ``` The code of the Team entity ```php /** * @ORM\Entity(repositoryClass=TeamRepository::class) * @ORM\Table(name="team") * @ORM\HasLifecycleCallbacks() */ class Team { use TimestampableTrait; /** * @var \Ramsey\Uuid\UuidInterface * * @ORM\Id * @ORM\Column(type="uuid", unique=true) * @ORM\GeneratedValue(strategy="CUSTOM") * @ORM\CustomIdGenerator(class=UuidGenerator::class) */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $description; /** * @ORM\ManyToOne(targetEntity=Account::class) * @ORM\JoinColumn(nullable=false) */ private $account; /** * @ORM\ManyToOne(targetEntity=User::class) * @ORM\JoinColumn(nullable=false) */ private $manager; ``` The code of the Account entity ```php /** * @ORM\Entity(repositoryClass=AccountRepository::class) * @ORM\Table(name="account") * @ORM\HasLifecycleCallbacks() */ class Account { use TimestampableTrait; /** * @var \Ramsey\Uuid\UuidInterface * * @ORM\Id * @ORM\Column(type="uuid", unique=true) * @ORM\GeneratedValue(strategy="CUSTOM") * @ORM\CustomIdGenerator(class=UuidGenerator::class) */ private $id; /** * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * @ORM\Column(name="state", type="string", length=255) */ private $state; ``` And the code of the User entity ```php class User { use TimestampableTrait; /** * @var \Ramsey\Uuid\UuidInterface * * @ORM\Id * @ORM\Column(type="uuid", unique=true) * @ORM\GeneratedValue(strategy="CUSTOM") * @ORM\CustomIdGenerator(class=UuidGenerator::class) */ private $id; /** * @ORM\Column(type="string", length=180, unique=true) */ private $email; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $firstName = ''; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $lastName = ''; /** * @ORM\ManyToMany(targetEntity=Account::class) */ private $accounts; /** * @ORM\ManyToMany(targetEntity=Team::class) */ private $teams; ``` What could be wrong? As I read in articles about using criteria in the Entity everything should be fine, but it doesn't Could someone help me to understand what the wrong here?
admin closed this issue 2026-01-22 15:38:21 +01:00
Author
Owner

@greg0ire commented on GitHub (Jun 29, 2021):

I have an issue
vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php line 44

Uuuuh… that's not an issue, that's a filename.

Search by criteria error

I doubt this is the actual error message you are getting.

If by chance you are using Symfony, consider reading this: https://symfony.com/doc/current/contributing/code/stack_trace.html , it might help you help us help you.

@greg0ire commented on GitHub (Jun 29, 2021): > I have an issue vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php line 44 Uuuuh… that's not an issue, that's a filename. > Search by criteria error I doubt this is the actual error message you are getting. If by chance you are using Symfony, consider reading this: https://symfony.com/doc/current/contributing/code/stack_trace.html , it might help you help us help you.
Author
Owner

@nyatMeat commented on GitHub (Jun 29, 2021):

I have an issue
vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php line 44

Uuuuh… that's not an issue, that's a filename.

Search by criteria error

I doubt this is the actual error message you are getting.

If by chance you are using Symfony, consider reading this: https://symfony.com/doc/current/contributing/code/stack_trace.html , it might help you help us help you.

I'm sorry. Didn't copy the whole output.
The problem is

Undefined index 'account'

But in entity Team account field is exists, and when I try to filter collection by criteria I am getting this error.
Might be something wrong with relations? I didn't find the answer on stackowerflow and github

@nyatMeat commented on GitHub (Jun 29, 2021): > > I have an issue > > vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php line 44 > > Uuuuh… that's not an issue, that's a filename. > > > Search by criteria error > > I doubt this is the actual error message you are getting. > > If by chance you are using Symfony, consider reading this: https://symfony.com/doc/current/contributing/code/stack_trace.html , it might help you help us help you. I'm sorry. Didn't copy the whole output. The problem is ``` Undefined index 'account' ``` But in entity Team `account` field is exists, and when I try to filter collection by criteria I am getting this error. Might be something wrong with relations? I didn't find the answer on stackowerflow and github
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6771