SQL到Hibernate查询转换

时间:2011-07-21 12:26:28

标签: sql hibernate

我遇到了一个问题,无法继续前进,因为我无法从SQL转换为HSQL。这是de SQL:

SELECT * FROM live_information i, live_matches_away ma, live_matches_home mh, 
live_matches m LEFT JOIN live_periods lp ON lp.match_id=m.id LEFT JOIN live_results r ON 
r.match_id=m.id LEFT JOIN live_scorers s ON s.match_id=m.id WHERE i.match_id=m.id AND 
ma.match_id=m.id AND mh.match_id=m.id AND day=20 AND month=07 AND year=2011

我将它转换为Hibernate,但是我收到了一个错误,我不明白LEFT JOIN如果没有ON怎么办?

这是我的HSQL:

from LiveMatches m, LiveInformation i, LiveMatchesAway ma, LiveMatchesHome mh left join 
LivePeriods lp on lp.liveMatches.id=m.id left join LiveResults r on 
r.liveMatches.id=m.id left join LiveScorers s on s.liveMatches.id=m.id where 
i.liveMatches.id=m.id AND ma.liveMatches.id=m.id AND mh.liveMatches.id=m.id AND 
lp.liveMatches.id=m.id AND r.liveMatches.id=m.id AND s.liveMatches.id=m.id AND m.day=" 
+ day + " AND m.month=" + month + " AND m.year=" + year;

这是错误:

org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: on near 
line 1, column 224

感谢。

1 个答案:

答案 0 :(得分:1)

尝试将on替换为with

你可能想看看这里: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html