title: Spring Boot JPA Lazy Fetch is not working
body: <p>I have following two domain objects Suggestion and UserProfile</p>
  
  <p>They are mapped with each other in one to many relationship. When I fetch all suggestions using Spring Data JPA, I get corresponding user object with each suggestion objects. This result is observed even when I have set <code>fetch</code> as <code>FetchType.Lazy</code>. Following is my code:</p>
  
  <p><strong>Suggestion.java</strong></p>
  
  <pre><code>@Entity
  @Table(name="suggestion")
  @JsonIgnoreProperties({"suggestionLikes"})
  public class Suggestion {
  
  public Suggestion() {
      // TODO Auto-generated constructor stub
  }
  
  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  @Column(name="suggestion_id")
  private Integer suggestionId;
  
  @Column(name="description")
  private String description;
  
  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name="suggestion_by")
  private UserProfile user;
  
  //getters and setters
  }
  </code></pre>
  
  <p><strong>UserProfile.java</strong></p>
  
  <pre><code>@Entity
  @Table(name = "user_master")
  @JsonIgnoreProperties({"suggestions", "suggestionLikes"})
  public class UserProfile implements Serializable {
  
  /**
   * 
   */
  private static final long serialVersionUID = 7400472171878370L;
  
  
  public UserProfile() {
  
  }
  
  
  @Id
  @NotNull
  @Column(name = "username", length = 55)
  private String userName;
  
  @NotNull
  @Column(name = "password")
  private String password;
  
  @OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
  private Set&lt;Suggestion&gt; suggestions;
  
  //getters and setters
  }
  </code></pre>
  
  <p>Following is the <strong>service</strong> which fetches the records:</p>
  
  <pre><code>@Override
  @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
  public List&lt;Suggestion&gt; getAllSuggestion() {
      return suggestionRespository.findAll();;
  }
  </code></pre>
  
  <p><strong>SuggestionRepository:</strong></p>
  
  <pre><code>@Repository
  public interface SuggestionRespository extends JpaRepository&lt;Suggestion, 
  Integer&gt; {
  
      public List&lt;Suggestion&gt; findAll();
  }
  </code></pre>
  
  <p>Following is the <strong>Application</strong> class:</p>
  
  <pre><code>@EnableTransactionManagement
  @SpringBootApplication
  public class AngularSpringbootApplication {
  
  public static void main(String[] args) {
      SpringApplication.run(AngularSpringbootApplication.class, args);
  }
  }
  </code></pre>
  
  <p><strong>application.properties:</strong></p>
  
  <pre><code>spring.datasource.url=jdbc:mysql://localhost:3306/plan_trip
  spring.datasource.username=root
  spring.datasource.password=root
  
  spring.jpa.properties.hibernate.dialect = 
  org.hibernate.dialect.MySQL5InnoDBDialect
  spring.jpa.hibernate.ddl-auto = update
  spring.jackson.serialization.fail-on-empty-beans=false
  </code></pre>
  
  <p>Response received when <code>getAllSuggestions()</code> is executed:</p>
  
  <pre><code>[
  {
      "suggestionId": 2,
      "description": "Germanyi!",
      "createdBy": "vinit2",
      "createdDate": "2018-06-19T10:38:32.000+0000",
      "modifiedBy": "vinit2",
      "modifiedDate": "2018-06-19T10:38:32.000+0000",
      "user": {
          "userName": "vinit2",
          "password": 
  "$2a$10$.hP0sQWpl6qqDKiNTkiu0OciQeHRFnkEbEWcDvnv1HY4QCi2tKo.2",
          "firstName": "Vinit2",
          "lastName": "Divekar2",
          "emailAddress": "vinit@gmail.com",
          "createdBy": null,
          "modifedBy": null,
          "createdDate": "2018-06-04",
          "modifiedDate": "2018-06-04",
          "isActive": "1",
          "handler": {},
          "hibernateLazyInitializer": {}
      }
  },
  {
      "suggestionId": 1,
      "description": "Vasai!",
      "createdBy": "vinit1",
      "createdDate": "2018-06-19T10:37:38.000+0000",
      "modifiedBy": "vinit1",
      "modifiedDate": "2018-06-19T10:37:38.000+0000",
      "user": {
          "userName": "vinit1",
          "password": "$2a$10$D0RMSTWu03Jw7wC1/zqFxOOjb0Do24o/4mq2PhDhRUyBrs8bdGvUG",
          "firstName": "Vinit1",
          "lastName": "Divekar1",
          "emailAddress": "vinit@gmail.com",
          "createdBy": null,
          "modifedBy": null,
          "createdDate": "2018-06-04",
          "modifiedDate": "2018-06-04",
          "isActive": "1",
          "handler": {},
          "hibernateLazyInitializer": {}
      }
  }
  </code></pre>
  
  <p>]</p>
  
  <p>Expected response:</p>
  
  <pre><code>[{
      "suggestionId": 2,
      "description": "Germanyi!",
      "createdBy": "vinit2",
      "createdDate": "2018-06-19T10:38:32.000+0000",
      "modifiedBy": "vinit2",
      "modifiedDate": "2018-06-19T10:38:32.000+0000"
  },
  {
      "suggestionId": 1,
      "description": "Vasai!",
      "createdBy": "vinit1",
      "createdDate": "2018-06-19T10:37:38.000+0000",
      "modifiedBy": "vinit1",
      "modifiedDate": "2018-06-19T10:37:38.000+0000"
  }
  ]
  </code></pre>
  
  <p>When I have declared <code>FetchType</code> as <code>Lazy</code>, I should not get User objects (in JSON) when I execute <code>findAll()</code>on Suggestion entity.</p>
  
  <p>What am I missing here?</p>