Employee (empCode, empAddress, email)
LoginUser (userName, isLocked, empCode(fk @oneToOne))
LoginUser table contains empCode as foreign key.
Employee{
private String empCode;
private String empAddress;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "employee", orphanRemoval = true, cascade = CascadeType.ALL)
private LoginUser
}
LoginUser{
private String userName;
private Boolean isLocked;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "empCode")
private Employee employee;
}
When I am trying to fetch a employee object, in query in console I can see it’s fetching employee details & login details too. Then, stackoverflow error
emp.getLoginUser(),
In trace, it’s showing it’s fetching both table, then shows StackOverflow error, even If I provide fetchtype lazy
If fetchtype is provided, then why eager loading or something else?