【发布时间】:2012-06-25 12:28:48
【问题描述】:
我在 Jboss 5.1 中使用 Hibernate EntityManager 3.4.0.GA。但是,尽管在我的 mysql 控制台中,查询似乎工作正常。我收到以下错误
sqlstate s0022 引起:javax.persistence.PersistenceException:org.hibernate.exception.SQLGrammarException:无法执行查询 原因:java.sql.SQLException:找不到列'code'。
我有两张表,一张是带有字段 id、code、type 的 Station,另一张是描述可能组合的 manyToMany 表
+------------+--------+--------+
| ID | | type | code |
+------------+--------+--------+
| 1 | AP | LAX |
| 2 | AP | JFK |
| 3 | AP | LHR |
| 4 | AP | MAN |
+------------+--------+--------+
+------------+--------+--------+
| depStationId | destStationId |
+------------+--------+--------+
| 1 | 2 |
| 1 | 3 |
| 2 | 1 |
| 3 | 1 |
+------------+--------+--------+
我调用的本机查询是
select d.code as origin, a.code as destination from DepDest dd
inner join STATIONS d on dd.depStationId=d.id and d.type=?1
inner join STATIONS a on dd.destStationId=a.id and a.type=?2
这似乎与查询中的双左连接和相同的列名有关。我找到了这个亲戚,但仍然没有解决方法。
https://hibernate.onjira.com/browse/HHH-3988
谁能建议一个解决方法 谢谢
【问题讨论】:
标签: mysql jpa inner-join