DDC-1051: Generated SQL Query Missing Table/Join Constraint leading to SQL Syntax Error #1312

Closed
opened 2026-01-22 13:09:54 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 28, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user webb.roger:

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.

Originally created by @doctrinebot on GitHub (Feb 28, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user webb.roger: 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.
admin added the Bug label 2026-01-22 13:09:54 +01:00
admin closed this issue 2026-01-22 13:09:55 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 28, 2011):

Comment created by webb.roger:

Problem was due to a missing "orm:" prefix for symfony annotations. Thanks.

@doctrinebot commented on GitHub (Feb 28, 2011): Comment created by webb.roger: Problem was due to a missing "orm:" prefix for symfony annotations. Thanks.
Author
Owner

@doctrinebot commented on GitHub (Feb 28, 2011):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Feb 28, 2011): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1312