I have an object that contains a list of options. The list of options is represented as a OneToMany relationship. Each Option then has a OneToMany relationship to values via a Join Table as below:
Code:
@OneToMany(fetch=FetchType.EAGER)
@JoinTable(name="OptionValue",
joinColumns = @JoinColumn(name="option_id", referencedColumnName="id"),
inverseJoinColumns = @JoinColumn(name="externalId", referencedColumnName="partNumber")
)
@IndexColumn(name = "position")
@XStreamOmitField
private List<ValueItem> values;
An individual Option may have values that point to the same OptionValue entity. However when the values list of the Option are loaded I would like unique Java objects for each ValueItem.
Code:
P -> Options |--> Opt1 -> Values |-> Val1
| |-> Val2
| |-> Val3
|
|---> Opt2-> Values |-> Val1
| |-> Val3
I would like Val1, Val2, Val3 to be unique objects between Opt1 and Opt2. So Val1 and Val3 are different Java objects between Opt1 and Opt2. Is this possible?