这个查询,它曾经有效,现在不再有效。(我正在切换到注释,这是剩下的两个损坏的测试之一。)
我有三张桌子:
+---------------+
| Competition |
+---------------+
| competitionId |
| . . . |
+---------------+
+---------------+
| Competitor |
+---------------+
| competitorId |
| . . . |
+---------------+
+------------------------+
| CompetitionCompetitors |
+------------------------+
| competitionId |
| competitorId |
+------------------------+
曾经有效的代码/查询是
Query query = session.createQuery(
"select c.id from Competition c join c.competitors co where co.id = :competitorId" );
query.setParameter( "competitorId", competitor.getCompetitorId() );
List list = query.list();
以下是来自 Hibernate 的一些前面的 SQL 日志记录,以及错误消息:
Hibernate: update db.competition set competitorId=? where competitionId=?
Hibernate: update db.competition set competitorId=? where competitionId=?
Hibernate: update db.competition set competitorId=? where competitionId=?
17:12:49,232 WARN JDBCExceptionReporter:233 - SQL Error: 1054, SQLState: 42S22
17:12:49,240 ERROR JDBCExceptionReporter:234 - Unknown column 'competitorId' in 'field list'
(必须承认,我很惊讶地看到查询发生了更新。)
以下是比赛中的注释:
@OneToMany( targetEntity = Competition.class )
@JoinColumn( name = "competitorId" )
private Set< Competitor > competitors = new TreeSet< Competitor >();
我吹了什么?