title: spring rest lazy loading with hibernate
body: <p>I am trying to develop spring rest api with hibernate.
  after searching in google, I have not find solution to lazy loading.
  I have two entity like below:</p>
  
  <p>University.java</p>
  
  <pre><code>@Entity()
  @Table(schema = "core", name = "university")
  public class University extends BaseEntity {
  
      private String uniName;
      private String uniTelephon;
  
  
      @LazyCollection(LazyCollectionOption.FALSE)
      @OneToMany(fetch = FetchType.LAZY, mappedBy = "university", cascade = CascadeType.ALL)
      @JsonManagedReference
      private List&lt;Student&gt; students;
  
  //setter and getter
  }
  </code></pre>
  
  <p>Student.java</p>
  
  <pre><code>@Entity
  @Table(schema = "core",name = "student")
  public class Student {
  
      @Id
      @GeneratedValue            
      private long id;        
  
      private String firstName;        
  
      private String lastName;        
  
      private String section;
  
      @ManyToOne(fetch=FetchType.LAZY)
      @JoinColumn(name = "UNIVERSITY_ID",nullable = false)
      @JsonBackReference
      private University university;
      // setter and getter
  }
  </code></pre>
  
  <p>any my rest end point</p>
  
  <pre><code>@GetMapping("/list")
  public ResponseEntity list() throws Exception {
      // I need to return just Universities But it return it eagerly with their students
      return new ResponseEntity(this.universityService.findAll(), HttpStatus.OK);
  }
  </code></pre>
  
  <p>after calling the rest api, it return university with all students.</p>
  
  <p>There is a way to tell Jackson to not serialize the unfetched objects or collections?</p>
  
  <p>Can somebody help me with a proved solution?</p>