QueryDSL 中的根路径是什么?你能举个例子解释一下吗?

What is root path in QueryDSL? Can you explain with an example?

我有以下两个实体 classes:国家和类型

@Entity
@Table(name = "countries")
public class Country {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id ;

    @Column(name = "iso_code")
    private String isoCode;

    public Country() {
    }

    public Country(String isoCode) {
        this.isoCode = isoCode;
    }

    public Country(int id, String isoCode) {
        this.id = id;
        this.isoCode = isoCode;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getIsoCode() {
        return isoCode;
    }

    public void setIsoCode(String isoCode) {
        this.isoCode = isoCode;
    }

       @Override
    public String toString() {
        return "Country{" +
                "id=" + id +
                ", isoCode='" + isoCode + '\'' +
                '}';
    }
}


@Entity
@Table(name = "types")
public class Type {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    @Column(name = "type")
    private String type;

 @ManyToOne
@JoinColumn(name = "country_id")
private Country country;

    @ManyToOne
    @JoinColumn(name = "group_id")
    private Group group;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Group getGroup() {
        return group;
    }

    public void setGroup(int priority) {
        this.group = group;
    }
}

我正在尝试使用存储库中的以下内容检索组 class:

        QType qType = QType.type1;
        QCountry qCountry = QCountry.country;
        QGroup qGroup = QGroup.group;
        QGroup qGroup1 = qType.group;

        JPAQuery queryGroup = new JPAQuery(em);

        QueryBase queryBaseGroups = queryGroup.from(qGroup).innerJoin(qGroup1, qGroup).innerJoin(qType.country, qCountry);

但是,我收到错误 -

java.lang.IllegalArgumentException: 未声明的路径 'type1'。将此路径作为源添加到查询中以便能够引用它。

JPA 新手。我在这里做错了什么?

因此,通过将 qType 添加到查询中的 from 函数解决了这个问题。

    QueryBase queryBaseGroups = queryGroup.from(qGroup, qType).innerJoin(qGroup1, qGroup).innerJoin(qType.country, qCountry);