Вопрос

I have two entities:

  1. User entity with two fields are: id (@id), username
  2. Profile entity with two fields are: user(@OneToOne,targetEntity="User"), fullname

But when I make a query try from things I read an JPA book:

SELECT p from Profile p where p.user.username = 'john'

It alerts to me a message:

[Syntax Error] line 0, col 55: Error: Expected =, <, <=, <>, >, >=, !=, got '.'

Это было полезно?

Решение

As of the current EBNF, the syntax you used is invalid in Doctrine 2 ORM. You will have to join the related entity as following:

SELECT
    p
FROM
    Profile p
JOIN
    p.user u
WHERE
    u.username = :username
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top