0

我正在尝试创建一个 HQL 查询以将选择结果与另一个表连接起来。我目前拥有的是

SELECT e FROM Experience e JOIN (SELECT f FROM Follow f WHERE f.username = :username AND f.contentType = :contentType) AS A ON (e.experienceId = A.contentId);

它当前有效的 SQL 等效项是

SELECT t_experiences.* FROM t_experiences JOIN (SELECT * FROM t_follows WHERE t_follows.username = :username AND t_follows.content_type = :contentType) AS A ON (t_experiences.experience_id = A.content_id);

wheret_experiences.experience_id等价于Experience.experienceId等。HQL 中的当前错误是第一个(unexpected token: (错误的。

任何帮助将不胜感激!

4

1 回答 1

0

你为什么不试试这个:

SELECT e.experienceId FROM Experience e, Follow f WHERE f.username = :username AND f.contentType = :contentType AND (e.experienceId = f.contentId);

我认为这应该对你有用。

Note: Replace e.experienceId by parameters which you want.

于 2013-06-11T09:38:47.493 回答