title: Can we use LAZY LOADING on One-to-many Relationship in Hibernate 5?
body: <p>I tried to use LAZY LOADING when loading information of Match without list of live links. But the result always fetch all links in Match.</p>
  
  <p><strong>My question is: 
  Is it possible to use LAZY LOAD for One-to-many relationship in Hibernate 5? If we can, please help me to check my code.</strong></p>
  
  <p><strong>Thank you very much!</strong></p>
  
  <p>I have following code: </p>
  
  <pre><code>@Entity
  @Table(name = "match_info")
  public class MatchInfoModel extends AuditModel {
  
      @Id
      @Column(name = "MATCH_ID")
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long matchId;
  
      @Column(name = "STADIUM_NAME")
      private String stadiumName;
  
      @Column(name = "START_TIME")
      private Date startTime;
  
      @OneToMany(mappedBy = "matchInfoModel", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
      private Set&lt;LiveStreamModel&gt; liveStreamsSet;    
  }
  
  
  @Entity
  @Table(name = "live_stream")
  public class LiveStreamModel extends AuditModel {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name = "LIVE_LINK_ID")
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long liveLinkId;
  
      @Column(name = "LINK")
      private String link;
  
      @Column(name = "SPEED")
      private String speed;
  
      @Column(name = "ORDER_NUMBER")
      private int orderNumber;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "MATCH_ID")
      @JsonProperty(access = Access.WRITE_ONLY)
      private MatchInfoModel matchInfoModel;
  }
  </code></pre>
  
  <p>My Query function:</p>
  
  <pre><code>@Override
      public List&lt;MatchInfoModel&gt; getLiveMatches() throws Exception {
  
          Session session = getSession();
          CriteriaBuilder criteria = session.getCriteriaBuilder();
          CriteriaQuery&lt;MatchInfoModel&gt; criteriaQuery = criteria.createQuery(MatchInfoModel.class);
          Root&lt;MatchInfoModel&gt; matchInfoRoot = criteriaQuery.from(MatchInfoModel.class);
          criteriaQuery.select(matchInfoRoot);
  
          // Order by start time
          criteriaQuery.orderBy(criteria.asc(matchInfoRoot.get("startTime")));
          return session.createQuery(criteriaQuery).getResultList();
      }
  </code></pre>
  
  <p>My TRACE log: </p>
  
  <pre><code>2018-08-13 10:00:24 DEBUG org.hibernate.SQL - 
      select
          matchinfom0_.match_id as match_id1_4_,
          matchinfom0_.creat_date as creat_da2_4_,
          matchinfom0_.create_user as create_u3_4_,
          matchinfom0_.last_modified as last_mod4_4_,
          matchinfom0_.modified_user as modified5_4_,
          matchinfom0_.guest_team_id as guest_t10_4_,
          matchinfom0_.has_live_stream as has_live6_4_,
          matchinfom0_.host_team_id as host_te11_4_,
          matchinfom0_.league_name as league_n7_4_,
          matchinfom0_.stadium_name as stadium_8_4_,
          matchinfom0_.start_time as start_ti9_4_ 
      from
          match_info matchinfom0_ 
      order by
          matchinfom0_.start_time asc
  2018-08-13 10:00:25 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [BIGINT] - [1]
  2018-08-13 10:00:25 DEBUG org.hibernate.SQL - 
      select
          livestream0_.match_id as match_i12_3_0_,
          livestream0_.live_link_id as live_lin1_3_0_,
          livestream0_.live_link_id as live_lin1_3_1_,
          livestream0_.creat_date as creat_da2_3_1_,
          livestream0_.create_user as create_u3_3_1_,
          livestream0_.last_modified as last_mod4_3_1_,
          livestream0_.modified_user as modified5_3_1_,
          livestream0_.language as language6_3_1_,
          livestream0_.link as link7_3_1_,
          livestream0_.link_type as link_typ8_3_1_,
          livestream0_.match_id as match_i12_3_1_,
          livestream0_.order_number as order_nu9_3_1_,
          livestream0_.speed as speed10_3_1_,
          livestream0_.status as status11_3_1_ 
      from
          live_stream livestream0_ 
      where
          livestream0_.match_id=?
  2018-08-13 10:00:25 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [BIGINT] - [7]
  2018-08-13 10:00:25 DEBUG org.hibernate.SQL - 
      select
          livestream0_.match_id as match_i12_3_0_,
          livestream0_.live_link_id as live_lin1_3_0_,
          livestream0_.live_link_id as live_lin1_3_1_,
          livestream0_.creat_date as creat_da2_3_1_,
          livestream0_.create_user as create_u3_3_1_,
          livestream0_.last_modified as last_mod4_3_1_,
          livestream0_.modified_user as modified5_3_1_,
          livestream0_.language as language6_3_1_,
          livestream0_.link as link7_3_1_,
          livestream0_.link_type as link_typ8_3_1_,
          livestream0_.match_id as match_i12_3_1_,
          livestream0_.order_number as order_nu9_3_1_,
          livestream0_.speed as speed10_3_1_,
          livestream0_.status as status11_3_1_ 
      from
          live_stream livestream0_ 
      where
          livestream0_.match_id=?
  2018-08-13 10:00:25 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [BIGINT] - [6]
  </code></pre>