I'm fairly new to Hibernate/JPA and would like to accomplish the following, where person.transactions would automatically display all policy.transactions where the person is the primary or secondary in the policy's quote. Person.transactions should be lazy-loaded but not actually stored (aka dynamic). I've tried @Formula
and @JoinColumnsOrFormulas
but it does not work.
@Entity
public class Policy {
@OneToOne
public Quote quote;
@OneToMany
public List<Transaction> transactions;
}
@Entity
public class Quote {
@OneToOne
public Person primary;
@OneToOne
public Person secondary;
}
@Entity
public class Person {
@Id
private int id;
private List<Transaction> transactions;
}
Comments
Post a Comment