Jira issue originally created by user stuartcarnie:
When using ->matching() on a PersistentCollection that is already loaded, it returns incorrect results when trying to match by id on a relationship.
// NOTE: the user property is a M:1 relationship of $entity
$c = new Criteria(Criteria::expr()->eq('user', $userId));
$res = $entity->getLikes()->matching($c);
// $res is empty, even if $userId exists
Comment created by @beberlei:
The problem is that matching a user by just the id doesn't work for in memory here.
You should use Criteria::expr()->eq('user', $user) instead. The ORM shouldnt allow $userId matching, but this is generic functionality we are reusing here, pretty hard to enforce this. I can take a look.
Fixed and introduced a BC break for this.
See 30f90a6#L0R31 for information.
Issue was closed with resolution "Fixed"