Hi.
I have two objects which one of them is Person.class, and another one is PhoneNumber.class.
There is a relationship between Person and PhoneNumber and a person may have more than one phonenumber. Their relationship is linked with this;
Code:
<class name="Person" table="persons">
<id name="id" column="ID">
<generator class="native">
<param name="sequence">SEQ_PERSON</param>
</generator>
</id>
<bag name="phoneNumbers" cascade="all" lazy="true">
<key not-null="true">
<column name="PERSON_ID" />
</key>
<one-to-many class="PhoneNumber" />
</bag>
</class>
Now, i want to get PhoneNumber list from Person using Criteria. But i couldn't find a solution about this. The important thing is that i want to get List of PhoneNumber, not a Person.
And this is the Person.class
Code:
public class Person {
private Long id;
private Collection phoneNumbers;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id= id;
}
public Collection getPhoneNumbers() {
return phoneNumbers;
}
public void setPhoneNumbers(Collection phoneNumbers) {
this.phoneNumbers= phoneNumbers;
}
}
How can i get this?
Thanks for any help.