hql join query:加入

时间:2017-08-27 08:30:14

标签: spring hibernate hql

我是hql的新手,我在一些网站上用来在spring框架中编写hql查询,但它会抛出" Path期望加入!"例外

我的查询是

"from GaugeCateSelect cs inner join PreferredUrl purl on cs.survey=purl.survey where purl.uuid=:uuid"

我想将这两个表与" 调查";

连接起来

请提前帮助我解决它。

更新

两个表,名称是 GaugeCateSelect PreferredUr l。 "调查"字段对于两个表都很常见。 uuid 位于PreferredUrl中。当我将uuid传递给PreferredUrl表时,我想从GaugeCateSelect获取所有数据。 (简而言之,将uuid传递给PreferredUrl,然后从PreferredUrl中找到调查编号并使用GaugeCateSelect表检查编号,如果存在则获取所有数据)

更新2

两个表之间没有主/外键引用关系。但普通实地调查

GaugeCateSelect类

class GaugeCateSelect {

    private int id; 
    private String categoryName;    
    private int posNeg; 
    private Survey survey;  //survey is in foreign key relationship of survey table

//Annotation, getters and setters were removed for easiness.

}

PreferredUrl class

public class PreferredUrl {

    private int preferredUrlId;
    private String uuid;
    private int enabled;
    private Survey survey;  //survey is in foreign key relationship of survey table

//Annotation, getters and setters were removed for easiness.

}

1 个答案:

答案 0 :(得分:0)

也许您应该检查您使用的Hibernate版本,因为加入不相关的实体时存在差异,如下所述:https://www.thoughts-on-java.org/how-to-join-unrelated-entities/