I have two Entities Person
and PersonImage
:
@Entity
public class Person {
....
@OneToMany(mappedBy = "person", cascade = { CascadeType.PERSIST,
CascadeType.REMOVE }, orphanRemoval = true, fetch = FetchType.LAZY)
private List<PersonImage> images;
....
}
@Entity
public class PersonImage {
....
@Lob
private byte[] content;
@ManyToOne
private Person person;
....
}
The problem is that when I insert a Person
(without any image attached to it), before Insert the images
list is null
. But after insert the list is an empty IndirectList
instance. I can see while debugging that it is changed from null
to {[]}
.
Why is this so? I would like it to be either a null or an Uninitialized IndirectList
(which should look like {IndirectList: not instantiated}
while debugging). How can I achieve this?