Is correct to use @OneToMany with @OneToOne?

Viewed 3594

I have a class Portfolio where the debts that the debtors have with different banks are kept. Therefore, a portfolio has a list of Debt objects and the annotation is @OneToMany.

This is Portfolio:     

@Entity
public class Portfolio extends PersistentEntity {
    @OneToMany
    private List<Debt> debts;

    /* Getters and setters */
}

And the class Debt:

@Entity
public class Debt extends PersistentEntity {
    @OneToOne
    private Portfolio portfolio;

    /* Getters and setters */
}

My question is what annotation to use in the Debt class. I understand it is @OneToOne because a debt belongs to a particular portfolio, but I was advised to use @ManyToOne. What I understand from this annotation is that a debt can be referenced by different portfolios. Is this correct?

1 Answers
Related