Make spring data jpa return related entities
I have relation set between two classes
Nested class:
@Column(name = "owner_id", nullable = false)
private UUID ownerId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "owner_id", nullable = false, insertable = false, updatable = false)
private Owner owner;
Owner class:
@OneToMany(mappedBy = "owner",
cascade = { CascadeType.PERSIST, CascadeType.REMOVE },
fetch = FetchType.LAZY)
private Set nestedSet;
In test I'm pre-persisting owner class in db, then set its id to nested entity and then store it with save repository method, when I'm calling nested.getOwner() on returned from the repository call entity, I have null. I tried to change
FetchType.LAZY to FetchType.EAGER
but it didn't work.