Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 查询集合<&燃气轮机;使用HQL_Hibernate_Jpa - Fatal编程技术网

Hibernate 查询集合<&燃气轮机;使用HQL

Hibernate 查询集合<&燃气轮机;使用HQL,hibernate,jpa,Hibernate,Jpa,我有这样的映射类: @Entity @Table(name = "contact", catalog = "pagesjaunes") public class Contact implements java.io.Serializable { private Integer id; private String name; private Set<Phone> phones = new HashSet<Phone>(0); [...]

我有这样的映射类:

@Entity
@Table(name = "contact", catalog = "pagesjaunes")
public class Contact implements java.io.Serializable {

    private Integer id;
    private String name;
    private Set<Phone> phones = new HashSet<Phone>(0);

    [...]

}



@Entity
@Table(name = "telephone", catalog = "pagesjaunes")
public class Phone implements java.io.Serializable {

    private Integer id;
    private Contact contact;
    private String phoneNumber;

    [...]
}
@实体
@表(name=“contact”,catalog=“pagesjaunes”)
公共类联系人实现java.io.Serializable{
私有整数id;
私有字符串名称;
专用集电话=新哈希集(0);
[...]
}
@实体
@表(name=“telephone”,catalog=“pagesjaunes”)
公共类Phone实现java.io.Serializable{
私有整数id;
私人接触;
私有字符串电话号码;
[...]
}
我可以在
Contact
HQL
进行类似的查询吗:


来自联系人,其中phones.phoneNumber=06487954
否,语法不正确
phones
是指向集合的路径,集合没有phoneNumber属性。您需要加入才能执行您想要的操作:

select c from Contact c
inner join c.phones [as] phone
where phone.phineNumber = '06487954'
这当然在本文中有解释

注意:
[as]
表示您可以将
用作
或省略它