1
프로젝트에 많은 엔터티가 있고 HQL 쿼리를 사용하여 여러 엔터티에서 데이터를 검색하려고합니다. HQL 쿼리에서 JOINS를 사용하여 엔티티에서 데이터를 검색하려고 시도하지만 코드가 실행될 때 예외가 생성됩니다. 다음HQL : HQL 쿼리에서 다중 내부 조인
org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [SELECT s.id, s.name, s.url, s.uuid, s.createdBy , t.id , u.id , u.name FROM com.insonix.qrata.models.Site s INNER JOIN s.topics t INNER JOIN User u WHERE lower(s.name) LIKE lower(:name) AND s.createdBy IN (:created_by) AND u.id = s.createdBy]
쿼리는 다음과 같습니다 : 예외가됩니다 다음
public class CommonEntity {
-------------------
private Long createdBy;
private String uuid;
------------------------
}
public class Site extends CommonEntity{
private long id;
private String url;
private String name;
private Category category;
private List<Topic> topics = new ArrayList<>(0);
---------------------------
}
public class Topic extends CommonEntity{
private int id;
private List<Site> sites = new ArrayList<Site>(0);
-----------------------------------
}
public class User extends CommonEntity
private long id;
private UserInfo userinfo;
--------------------------------
}
public class UserInfo extends CommonEntity{
private String firstname;
private String lastname;
}
처럼 필요한 결과를 얻을 수 있습니다 사용자와 사이트가 아무 관련이 없기 때문에이 '사용자 u INNER JOIN s.topics'를 작성하는 방법. –
아니요! 이제 'FROM Site, User u'라는 두 개의 테이블에서 데이터를 가져 와서 'INNER JOIN s.topics t'에 의해 't'로 사이트의 'topics'에 합류하고 사용자의 속성에 WHERE 절을 정의합니다 ... – maimoona