我有两个实体

   @Entity
    public class Tabulka{

@OneToMany(mappedBy = "tabulka")
    private List<VysledkyHraca> vysledkyHraca;
.
.
.

}




    @Entity
    public class VysledkyHraca{

    @ManyToOne
        private Tabulka tabulka;
.
.
.

    }


创建到表:具有ID和...的tabulka
和ID为..和id_tabulka的VysledkyHraca

如果我想检索所有禁忌...好吧,这很简单:

@NamedQuery(name = Tabulka.Q_GET_ALL_TABULKY, query = "SELECT t FROM Tabulka t ")


但现在我想检索所有tabulka,然后检索VysledkyHraca列表

我尝试使用此@NamedQuery(name = Tabulka.Q_GET_ALL_JOINTABULKY, query = "SELECT t FROM Tabulka t join t.vysledkyHraca"),但是它不起作用。寻求帮助

最佳答案

加入需要别名

如果只想获取它,请使用“ join fetch”(不带别名)

关于java - Java EE命名查询联接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6514498/

10-09 07:03