I have JPA annotated entity association as below
Code:
@Entity
@Table(name = "COLLECTIONSITE")
public class CollectionSite implements Serializable {
@OneToMany(mappedBy = "site", fetch = FetchType.LAZY)
@Where(clause = "EFF_START_DATE <> EFF_END_DATE")
private Collection<MiscData> miscData;
}
@Entity
@Table(name = "MISC_DATA")
public class MiscData implements Serializable{
@ManyToOne
@JoinColumn(name = "SITE")
private CollectionSite site;
}
This is resulting the following associations at different app flows. Thanks to Eclipse's Debug Variable panel's Copy Variables feature.
<!--
Correct Association -->
this CollectionSite (id=
229)
miscData PersistentBag (id=230)
bag ArrayList<E> (id=271)
elementData Object[10] (id=273)
[0] MiscData (id=274)
site CollectionSite (id=
229)
[1] MiscData (id=275)
site CollectionSite (id=
229)
[2] MiscData (id=276)
site CollectionSite (id=
229)
[3] MiscData (id=277)
site CollectionSite (id=
229)
modCount 4
size 4
<!--
InCorrect Association -->
this CollectionSite (id=
353)
miscData PersistentBag (id=354)
bag ArrayList<E> (id=357)
elementData Object[10] (id=372)
[0] MiscData (id=373)
site CollectionSite (id=
379)
[1] MiscData (id=374)
site CollectionSite (id=
379)
[2] MiscData (id=375)
site CollectionSite (id=
353)
modCount 3
size 3
Any thoughts on how the parent association is going wrong ?