-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDC-1001: Join statement fails #1586
Comments
Comment created by @beberlei: It seems either your mapping files are wrong, can you post the mappings of RoomMember? |
Comment created by rrafal@gmail.com: I simplified my code to the following and run the test again: /****
/****
$query = $this->em->createQuery('SELECT u FROM RoomMember m , User u WHERE m.user = u'); $query = $this->em->createQuery('SELECT u FROM RoomMember m JOIN m.user u'); I also tried to recreated this problem using the repository version of doctrine. I created same entities in sandbox environment (doctrine2-orm/tools/sandbox). I'm getting a different error message: PHP Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message '[Semantical Error] line 0, col -1 near 'SELECT u FROM': Error: Cannot select entity through identification variables without choosing at least one root entity alias.' in doctrine2-orm/lib/Doctrine/ORM/Query/QueryException.php:47 I'll attache my code from sandbox. |
Comment created by @beberlei: Ah yes, the query you want to do is not possible. I have only seen that now. You have to select the "m" if you have RoomMember in the FROM clause. That is what the exception in the sandbox is about. Are you using an older version of Doctrine (RC1 or less) for your project? The exception is realtively new |
Issue was closed with resolution "Invalid" |
Comment created by rrafal@gmail.com: Ok, thanks for the explanation. I'll just used the alternative DQL, it works perfectly: I'm using doctrine ORM 2.0.0 |
Jira issue originally created by user rrafal@gmail.com:
I tried to execute this DQL statement:
SELECT u FROM RoomMember m JOIN m.user u WHERE m.room = :roomId
It failed with this error:
class_parents(): object or string expected
Doctrine/ORM/Mapping/ClassMetadataFactory.php:222
Doctrine/ORM/Mapping/ClassMetadataFactory.php:245
Doctrine/ORM/Mapping/ClassMetadataFactory.php:169
Doctrine/ORM/EntityManager.php:247
Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:223
Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:76
Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:98
Doctrine/ORM/AbstractQuery.php:527
I rewrite the query like this, and it works:
SELECT u FROM RoomMember m , User u WHERE m.user = u AND m.room = :roomId
Let me know if you need more information.
Rafal - rrafal@gmail.com
The text was updated successfully, but these errors were encountered: