This question is similar/related to this other, but more specifically focused on a non-owning @OneToMany
relation side. Given the following mapped getter:
...
private List<Leaf> leaves;
...
@OneToMany(mappedBy = "extkey")
@LazyCollection(LazyCollectionOption.TRUE)
public List<Leaf> getLeaves() {
return leaves;
}
...
What would be the impact of adding the transient
modifier to leaves
field in this case?
The relation is lazy and 'reversed', ie the owning side is Leaf
object. The code was working before and looks working still now, but I wonder about any undesired subtle side effect, since transient
has some peculiarity in JPA context. I needed this as passing the entity instance to an external Gson lib would loop and stackoverflow
, I guess bc the bi-directional relation creates a loop and I could avoid it using transient field. Thanks