我有两个实体:
User
包含两个字段的实体是:id
(@id),username
Profile
包含两个字段的实体是:user
(@ OneToOne,targetEntity =“User”),fullname
但是当我查询时,我会阅读一本JPA书:
SELECT p from Profile p where p.user.username = 'john'
它向我发出了一条消息:
[Syntax Error] line 0, col 55: Error: Expected =, <, <=, <>, >, >=, !=, got '.'
答案 0 :(得分:0)
截至当前EBNF,您使用的语法在Doctrine 2 ORM中无效。您必须加入相关实体,如下所示:
SELECT
p
FROM
Profile p
JOIN
p.user u
WHERE
u.username = :username