我正在尝试使用在Hibernate 5.1之后添加的新的“ ON”子句。我试图在未关联的表/实体上运行查询,但出现异常提示我的语法错误。
代码
System.out.println(org.hibernate.Version.getVersionString()); //5.3.7.Final
String query = " SELECT i FROM Information i JOIN Cat c ON i.catId = c.id JOIN Data d ON c.data.id = d.data.id WHERE i.isNew = false AND i.creationTimestamp <= :offset";
Query typedQuery = entityManager.createQuery(query);
typedQuery.setMaxResults(fetchSize);
typedQuery.setParameter("offset", currentTimestamp);
return typedQuery.getResultList();
例外:
antlr.SemanticException: Path expected for join!
背景信息
我的语法似乎与休眠功能版本中使用的语法相同-> https://in.relation.to/2016/02/10/hibernate-orm-510-final-release/
我还遵循了本教程中使用的语法-> https://thoughts-on-java.org/how-to-join-unrelated-entities/