tecbot/AMFBundle — Issue #2: Not related for AMFBundle question
Author: cystbear
Created: 2011-11-29 15:40:08+00:00
State: open

Hi Thomas, I can not found your email, thus write here, sorry about this in advance.

I have found this your commit
https://github.com/doctrine/mongodb-odm/commit/ee37d65fb73a29c7d80ee8f2adc48665f59f7030

want ask you. I have next code

```
$qb = $this->createQueryBuilder();
$query = $this->createIsActiveQuery()
->field('userPrograms')
->elemMatch(
$qb->expr()
->field('program.$id')->equals(new \MongoId($program->getId()))
->field('isEnabled')->equals(true)
);

return $query;
```

here I am at userRepository, user have `userPrograms` field (embedded many).
`userPrograms` have reference one `program` (thus have `program.$id`).

After upgrade `doctrine-common` `doctrine-mongodb` and `doctrine-mongodb-odm` this code stop works with message
```
No mapping found for field 'program' in class 'Application\UserBundle\Document\User'
```

I have change first version of query for this:
```
$qb = $this->createQueryBuilder();
$query = $this->createIsActiveQuery()
->field('userPrograms')
->elemMatch(
$qb->expr()
->field('userPrograms.program.$id')->equals(new \MongoId($program->getId()))
->field('userPrograms.isEnabled')->equals(true)
);

return $query;
```

with this changes query works, at least not throw any error.
So my questions are:
1) Did I made correct changes?
2) Could you please explain your changes?
3) Did previous version of query works properly?