title: Spring Data Jpa Lazy Loading not working as expected
body: <p>Hey i am working on Spring Data jpa and i would like to fetch data lazily only.</p>
  
  <p>I am using lombook in my spring project</p>
  
  <p>I would like to fetch a user and his roles by email.</p>
  
  <p>I have few classes</p>
  
  <pre><code>@Entity
  @Table(name = "user")
  @Data
  public class User extends DateAudit {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
  
      private String name;
  
      @Column(columnDefinition = "char(50)")
      private String email;
  
      @Column(columnDefinition = "char(15)")
      private String phone;
  
      private String password;
  
      @Column(columnDefinition = "bit")
      private boolean isActive;
  
      @Column(columnDefinition = "ENUM('MALE', 'FEMALE', 'OTHER')")
      @Enumerated(EnumType.STRING)
      private Gender gender;
  
      @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
      private List&lt;UserRole&gt; userRoles;
  
      @OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
      private UserProfile userProfile;
  
  }
  </code></pre>
  
  <pre><code>@Entity
  @Table(name = "user_profile")
  @Data
  public class UserProfile extends DateAudit {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
  
      private String picture;
      private float avgRating;
  
      @Column(columnDefinition = "char(13)")
      private String cnic;
  
      @Temporal(TemporalType.DATE)
      private Date dateOfBirth;
  
      //relations
  
      @OneToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "user_id")
      private User user;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "city_id")
      private City city;
  }
  </code></pre>
  
  <pre><code>@Entity
  @Data
  @Table
  public class UserRole {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "user_id")
      private User user;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "role_id")
      private Role role;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "hospital_id")
      private Hospital hospital;
  }
  
  </code></pre>
  
  <p>And here is my user repository</p>
  
  <pre><code>@Repository
  public interface UserRepository extends CrudRepository&lt;User, Integer&gt; {
  
      @EntityGraph(attributePaths = {"userRoles"})
      User findByEmail(String email);
  }
  </code></pre>
  
  <p>Below is my action that i am using to fetch user</p>
  
  <pre><code>    @GetMapping("/test")
      public String test(){
  
          userRepository.findByEmail("admin@domain.com");
          return "test";
      }
  </code></pre>
  
  <p>I have added below property in application.properties</p>
  
  <pre><code>spring.jpa.properties.hibernate.show_sql=true
  </code></pre>
  
  <p>so when i hit my /test action from postman
  I see two queries executed in my application console.</p>
  
  <pre><code>Hibernate: select user0_.id as id1_21_0_, userroles1_.id as id1_23_1_, user0_.created_at as created_2_21_0_, user0_.updated_at as updated_3_21_0_, user0_.email as email4_21_0_, user0_.gender as gender5_21_0_, user0_.is_active as is_activ6_21_0_, user0_.name as name7_21_0_, user0_.password as password8_21_0_, user0_.phone as phone9_21_0_, userroles1_.hospital_id as hospital2_23_1_, userroles1_.role_id as role_id3_23_1_, userroles1_.user_id as user_id4_23_1_, userroles1_.user_id as user_id4_23_0__, userroles1_.id as id1_23_0__ from user user0_ left outer join user_role userroles1_ on user0_.id=userroles1_.user_id where user0_.email=?
  Hibernate: select userprofil0_.id as id1_22_0_, userprofil0_.created_at as created_2_22_0_, userprofil0_.updated_at as updated_3_22_0_, userprofil0_.avg_rating as avg_rati4_22_0_, userprofil0_.city_id as city_id8_22_0_, userprofil0_.cnic as cnic5_22_0_, userprofil0_.date_of_birth as date_of_6_22_0_, userprofil0_.picture as picture7_22_0_, userprofil0_.user_id as user_id9_22_0_ from user_profile userprofil0_ where userprofil0_.user_id=?
  </code></pre>
  
  <p>I am not interested in user profile. what am i doing wrong here.</p>