I'm trying to write a system which contains people and applications. Every person can apply for different applications.
I'm trying to apply a @oneToManyRelation
on the person object (when retriving a person from the db, I would like to recive a list with every aplication that they applied for).
Here is my code:
@Entity
@Table(name="t_person")
public class person extends Model {
@id
@column(name="PERSON_ID")
private string ID;
more properties...
@OneToMany(targetEntity=application.class, mappedBy="SOLDIER_ID")
private ArrayList<application> ApplicationList;
public ArrayList<application> getApplicationList() {
return ApplicationList;
}
public void setApplicationList(ArrayList<application> applicationList) {
ApplicationList = applicationList;
}
}
@Entity
@Table(name="T_APPLICATION")
public class application extends Model {
@Id
@Column(name="APPLICATION_ID")
private int Id;
@ManyToOne
@JoinColumn(name="PERSON_ID")
private person Person;
}
I'm using Activator and an Oracle DB. When I retrieve an application I get the person object ok, but when retriving a person, the application list is null.
Where am I going wrong?
i found the problem. the problem is that applicationList is an ArrayList<> and not a List<>. as soon as i change the ArrayList to a List. it's working.