Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Invalid
-
Affects Version/s: 2.0
-
Fix Version/s: None
-
Component/s: DQL, Mapping Drivers, ORM
-
Security Level: All
-
Labels:None
-
Environment:RedHat Enterprise, PHP 5.3.4, Symfony2 (Sandbox PR7)
Description
SELECT u, uc, ur
FROM ARN\EntityBundle\Entity\Users u
INNER JOIN u.contact_info uc
INNER JOIN u.user_roles ur
WHERE u.username = :username
Generates the following SQL Query
SELECT u0_.user_id AS user_id0, u0_.username AS username1, u0_.password AS password2, u0_.contact_info_id AS contact_info_id3, u0_.user_active AS user_active4, u0_.user_date AS user_date5, u0_.office_id AS office_id6, u0_.superuser AS superuser7, c1_.contact_info_id AS contact_info_id8, c1_.first_name AS first_name9, c1_.last_name AS last_name10, c1_.address AS address11, c1_.city_id AS city_id12, c1_.zip AS zip13, c1_.email AS email14, u2_.user_role_id AS user_role_id15, u2_.role AS role16, u0_.contact_info_id AS contact_info_id17, c1_.city_id AS city_id18 FROM users u0_ INNER JOIN contact_info c1_ ON u0_.contact_info_id = c1_.contact_info_id INNER JOIN WHERE u0_.user_id = ?')
Notice the "INNER JOIN WHERE", this is the problem.
The mapping is as follows:
Users->user_roles
/**
- @orm:OneToMany(targetEntity="UserRoles", mappedBy="user")
*/
protected $user_roles;
UserRoles->user
/**
- @ManyToOne(targetEntity="Users", inversedBy="user_roles")
- @JoinColumn(name="user_id", referencedColumnName="user_id")
*/
protected $user;
Let me know if you need any more information. Happy to help. Thanks.
Problem was due to a missing "orm:" prefix for symfony annotations. Thanks.