i have my mapped classes like that:
@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;
[...]
}
Can I make a query like that on Contact
with HQL
:
from Contact where phones.phoneNumber = 06487954
No, the syntax is incorrect. phones
is a path to a Set, and Set doesn't have a phoneNumber attribute. You need a join to do what you want:
select c from Contact c
inner join c.phones [as] phone
where phone.phineNumber = '06487954'
This is of course explained in the documentation.
Note: [as]
means that you can use as
or omit it.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments