Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Dynamic Hibernate field storing indirect child entities

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