I tried with this :
@OneToOne(mappedBy = "user", fetch = FetchType.LAZY)
private UserInfo userInfo;
But the above code doesn't fetch lazily.
And also tried with the following code :
@Entity
@NamedEntityGraph(name = "User.detail", attributeNodes = {} )
public class User extends AbstractEntity {
@Enumerated(EnumType.ORDINAL)
@Column(name = "country", nullable = false)
private Country country;
@Column(name = "mobile_no", nullable = false)
private String mobileNo;
@Column(name = "password", nullable = false)
private String password;
@OneToOne(mappedBy = "user", fetch = FetchType.LAZY)
private UserInfo userInfo;
// Getter & setter
}
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
@EntityGraph(value = "User.detail", type = EntityGraphType.FETCH)
User findById(Long id);
}
This too doesn't work.
Can anybody help me?