I know that lazy loading can't be done if you have a two-way relationship in a one-to-one relationship.
So I read about How can I make a JPA OneToOne relation lazy.
The article says that you can't create a proxy in a one-to-one relationship, but I can't quite understand it.
I think There is no difference between a many-to-one relationship and a one-to-one relationship. He says that in a many-to-one relationship you can create a proxy because you can get the value from FK.
However, one-to-one relationships can also get values with FK, there is no explanation as to why exactly one-to-one relationships can't only get values.
Can someone please explain clearly?
// one to one
class Address {
..
@OnetoOne(fetch = LAZY)
@JoinColumn(~)
private Order order;
}
class Order {
..
@OnetoOne(mappedBy = order, fetch = LAZY)
private Address address; // LAZY not wokring
}
// ManyToOne
public class Member {
@ManyToOne(fetch = LAZY)
@JoinColmn(~)
public Team team; // LAZY working!
}
I think these two are different. I know the PK values equally, so why doesn't only the one-to-one relationship do lazy loading?