Currently I have two tables in my database Encounters and Referrals:
There is a one to many relationship between these two tables. Currently they are linked together with foreign keys. Right now I have
public class Encounter extends JPASupport implements java.io.Serializable {
@Column(name="referralid", unique=false, nullable=true, insertable=true, updatable=true)
public Integer referralid;
}
But what I really want is
public class Encounter extends JPASupport implements java.io.Serializable {
..........
@OneToMany(cascade=CascadeType.PERSIST)
public Set<Referrals> referral;
............
}
So that I can eventually do a query like this:
List<Encounter> cases = Encounter.find(
"select distinct p from Encounter p join p.referrals as t where t.caseid =103"
).fetch();
How do I tell JPA that even though I have non-standard column names for my foreign keys and primary keys that its the object models that I want linked, not simply the integer value for the keys?
Does this make sense? I hope so. Thanks in advanced!