Title: When Query to Parent, Child also being fetched, Hibernate
Tags: java;json;hibernate
Question: In my application there are entities that have a one-to-many relationship. When I query the parent, children are also getting fetched. I want to fetch only the parent. I tried by adding ```fetchType``` as ```Lazy```, but it still fetches the children. The entities are as follows:

```
  Parent Entity
```

```@Entity
@Table(name = "INSTITUTE_LIST_MST")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "listId")
public class InstituteInfoMaster
{
    @Id
    @Column(name = "LIST_ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer listId;

    @Column(name = "LIST_DESC")
    private String description;

    @Column(name = "LIST_VALUE")
    private String value;

    @Column(name = "URL")
    private String url;

    @Column(name = "LOGO", unique = false, length = 100000)
    private byte[] logo;

    // @JsonProperty("instituteInfoDetails")
    // @JsonBackReference
    // @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "instituteInfotMaster", cascade = CascadeType.ALL)
    private Set<InstituteInfoDetails&gt; instituteInfoDetails = new HashSet<InstituteInfoDetails&gt;();

    @Column(name = "CREATED_DT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate = new Date();

    @Column(name = "CREATED_BY")
    private String createdBy;

    @Column(name = "UPDATED_DT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updatedDate;

    @Column(name = "UPDATED_BY")
    private String updatedBy;

    @Column(name = "RECORD_STATUS")
    private String recordStatus = "A";

    public Integer getListId()
    {
        return listId;
    }

    public void setListId(Integer listId)
    {
        this.listId = listId;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public String getValue()
    {
        return value;
    }

    public void setValue(String value)
    {
        this.value = value;
    }

    public Date getCreatedDate()
    {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate)
    {
        this.createdDate = createdDate;
    }

    public String getCreatedBy()
    {
        return createdBy;
    }

    public void setCreatedBy(String createdBy)
    {
        this.createdBy = createdBy;
    }

    public Date getUpdatedDate()
    {
        return updatedDate;
    }

    public void setUpdatedDate()
    {
        this.updatedDate = new Date();
    }

    public String getUpdatedBy()
    {
        return updatedBy;
    }

    public void setUpdatedBy(String updatedBy)
    {
        this.updatedBy = updatedBy;
    }

    public String getRecordStatus()
    {
        return recordStatus;
    }

    public void setActiveRecordStatus()
    {
        this.recordStatus = "A";
    }

    public void deleteRecord()
    {
        this.recordStatus = "D";
    }

    public Set<InstituteInfoDetails&gt; getInstituteInfoDetails()
    {
        return instituteInfoDetails;
    }

    public void setInstituteInfoDetails(Set<InstituteInfoDetails&gt; instituteInfoDetails)
    {
        // this.instituteInfoDetails = instituteInfoDetails;
        /*
         * for (InstituteInfoDetails ins : instituteInfoDetails) {
         * ins.setComListMaster(this); }
         */
        this.instituteInfoDetails = instituteInfoDetails;
    }

    public byte[] getLogo()
    {
        return logo;
    }

    public void setLogo(byte[] logo)
    {
        this.logo = logo;
    }

    public String getUrl()
    {
        return url;
    }

    public void setUrl(String url)
    {
        this.url = url;
    }

    public String getByteArrayString()
    {
        if (this.logo != null)
        {
            return new String(Base64.encode(this.logo));
        } else
        {
            return "";
        }
    }

}
```

```
  Child Entity
```

```@Entity
@Table(name = "INSTITUTE_LIST_DETAILS")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "listDtlId")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class InstituteInfoDetails
{
    @Id
    @Column(name = "LIST_DTL_ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer listDtlId;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "LIST_ID", nullable = false)
    // @JsonManagedReference
    private InstituteInfoMaster instituteInfotMaster;

    @Column(name = "LIST_DTL_VALUE")
    private String value;

    @Column(name = "LIST_DTL_DESC", length = 5000)
    private String description;

    @Column(name = "STRING1", length = 5000)
    private String string1;

    @Column(name = "STRING2", length = 5000)
    private String string2;

    @Column(name = "STRING3", length = 5000)
    private String string3;

    @Column(name = "SEQUENCE_NO")
    private Integer sequenceNo;

    @Column(name = "NUMBER1")
    private Double number1;

    @Column(name = "NUMBER2")
    private Double number2;

    @Column(name = "NUMBER3")
    private Double number3;

    @Column(name = "DOCUMENT", unique = false, length = 100000)
    private byte[] document;

    @Column(name = "DOCUMENT_TYPE", length = 1)
    private Integer documentType;

    @Column(name = "DOCUMENT1", unique = false, length = 100000)
    private byte[] document1;

    @Column(name = "DOCUMENT1_TYPE", length = 1)
    private Integer document1Type;

    @Column(name = "DOCUMENT2", unique = false, length = 100000)
    private byte[] document2;

    @Column(name = "DOCUMENT2_TYPE", length = 1)
    private Integer document2Type;

    @Column(name = "CREATED_DT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate = new Date();

    @Column(name = "CREATED_BY")
    private String createdBy;

    @Column(name = "UPDATED_DT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updatedDate;

    @Column(name = "UPDATED_BY")
    private String updatedBy;

    @Column(name = "RECORD_STATUS")
    private String recordStatus = "A";

    public Integer getListDtlId()
    {
        return listDtlId;
    }

    public void setListDtlId(Integer listDtlId)
    {
        this.listDtlId = listDtlId;
    }

    public String getValue()
    {
        return value;
    }

    public void setValue(String value)
    {
        this.value = value;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public InstituteInfoMaster getComListMaster()
    {
        return instituteInfotMaster;
    }

    public void setComListMaster(InstituteInfoMaster instituteInfotMaster)
    {
        this.instituteInfotMaster = instituteInfotMaster;
    }

    public Date getCreatedDate()
    {
        return createdDate;
    }

    public void setCreatedDate()
    {
        this.createdDate = new Date();
    }

    public String getCreatedBy()
    {
        return createdBy;
    }

    public void setCreatedBy(String createdBy)
    {
        this.createdBy = createdBy;
    }

    public Date getUpdatedDate()
    {
        return updatedDate;
    }

    public void setUpdatedDate(Date updatedDate)
    {
        this.updatedDate = updatedDate;
    }

    public String getUpdatedBy()
    {
        return updatedBy;
    }

    public void setUpdatedBy(String updatedBy)
    {
        this.updatedBy = updatedBy;
    }

    public String getRecordStatus()
    {
        return recordStatus;
    }

    public void setRecordStatus(String recordStatus)
    {
        this.recordStatus = recordStatus;
    }

    public InstituteInfoMaster getInstituteInfotMaster()
    {
        return instituteInfotMaster;
    }

    public void setInstituteInfotMaster(InstituteInfoMaster instituteInfotMaster)
    {
        this.instituteInfotMaster = instituteInfotMaster;
    }

    public String getString1()
    {
        return string1;
    }

    public void setString1(String string1)
    {
        this.string1 = string1;
    }

    public String getString2()
    {
        return string2;
    }

    public void setString2(String string2)
    {
        this.string2 = string2;
    }

    public String getString3()
    {
        return string3;
    }

    public void setString3(String string3)
    {
        this.string3 = string3;
    }

    public Integer getSequenceNo()
    {
        return sequenceNo;
    }

    public void setSequenceNo(Integer sequenceNo)
    {
        this.sequenceNo = sequenceNo;
    }

    public Double getNumber1()
    {
        return number1;
    }

    public void setNumber1(Double number1)
    {
        this.number1 = number1;
    }

    public Double getNumber2()
    {
        return number2;
    }

    public void setNumber2(Double number2)
    {
        this.number2 = number2;
    }

    public Double getNumber3()
    {
        return number3;
    }

    public void setNumber3(Double number3)
    {
        this.number3 = number3;
    }

    public byte[] getDocument()
    {
        return document;
    }

    public void setDocument(byte[] document)
    {
        this.document = document;
    }

    public Integer getDocumentType()
    {
        return documentType;
    }

    public void setDocumentType(Integer documentType)
    {
        this.documentType = documentType;
    }

    public byte[] getDocument1()
    {
        return document1;
    }

    public void setDocument1(byte[] document1)
    {
        this.document1 = document1;
    }

    public Integer getDocument1Type()
    {
        return document1Type;
    }

    public void setDocument1Type(Integer document1Type)
    {
        this.document1Type = document1Type;
    }

    public byte[] getDocument2()
    {
        return document2;
    }

    public void setDocument2(byte[] document2)
    {
        this.document2 = document2;
    }

    public Integer getDocument2Type()
    {
        return document2Type;
    }

    public void setDocument2Type(Integer document2Type)
    {
        this.document2Type = document2Type;
    }


}
```

```
  DAO
```

```@Override
    public List<InstituteInfoMaster&gt; getInstituteInfoMatserList()
    {
        logger.info("Listing Institute Master");
        Session session = sessionFactory.getCurrentSession();
        Query query = session.createQuery("select info from InstituteInfoMaster info");

        List<InstituteInfoMaster&gt; instituteInfoMaster = query.list();
        logger.info("List : " + instituteInfoMaster);
        return instituteInfoMaster;
    }
```

```
  Logs
```

```Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
Hibernate: select institutei0_.LIST_ID as LIST_ID22_10_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_0_, institutei0_.LIST_DTL_ID as LIST_DTL1_9_1_, institutei0_.CREATED_BY as CREATED_2_9_1_, institutei0_.CREATED_DT as CREATED_3_9_1_, institutei0_.LIST_DTL_DESC as LIST_DTL4_9_1_, institutei0_.DOCUMENT as DOCUMENT5_9_1_, institutei0_.DOCUMENT1 as DOCUMENT6_9_1_, institutei0_.DOCUMENT1_TYPE as DOCUMENT7_9_1_, institutei0_.DOCUMENT2 as DOCUMENT8_9_1_, institutei0_.DOCUMENT2_TYPE as DOCUMENT9_9_1_, institutei0_.DOCUMENT_TYPE as DOCUMEN10_9_1_, institutei0_.LIST_ID as LIST_ID22_9_1_, institutei0_.NUMBER1 as NUMBER11_9_1_, institutei0_.NUMBER2 as NUMBER12_9_1_, institutei0_.NUMBER3 as NUMBER13_9_1_, institutei0_.RECORD_STATUS as RECORD_14_9_1_, institutei0_.SEQUENCE_NO as SEQUENC15_9_1_, institutei0_.STRING1 as STRING16_9_1_, institutei0_.STRING2 as STRING17_9_1_, institutei0_.STRING3 as STRING18_9_1_, institutei0_.UPDATED_BY as UPDATED19_9_1_, institutei0_.UPDATED_DT as UPDATED20_9_1_, institutei0_.LIST_DTL_VALUE as LIST_DT21_9_1_ from INSTITUTE_LIST_DETAILS institutei0_ where institutei0_.LIST_ID=?
```

Comment: How do you know the children are also being fetched? With lazy-load, the children will only be fetched if you try to access them.

Comment: It seems likely that your code that produces the json format is including the collection of children. When it hits the collection, lazy loading will cause the DB to be queried.

Comment: i am receiving data in json format in which i am getting child values along with parent. also in logs child table query is being printed

Comment: I tried without JSON still its fetching child


Here is another answer: 
Make sure that when logging the root entity, its toString() implementation doesn't explicitly or implicitly iterate over the children collection:

```logger.info("List : " + instituteInfoMaster);
```
If the Hibernate ```Session``` is still open, and you try to serialize the root to JSON, when the children collection is accessed, it will be initialized and each associated child will be fetched too. To prove this, try adding ```@JsonIgnore``` to the children collection and check it again.
Try adding ```@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)``` on the children collection too and let the 2nd level collection cache handle this for you.


Comment for this answer: I tried with adding @JsonIgnore. in result i am receiving only Parent details but still in logs its showing query to child tables.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:09/22/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><json><hibernate>', 'Title': 'When Query to Parent, Child also being fetched, Hibernate', 'ViewCount': 58, 'id': 32723627, 'user_AboutMe': '', 'user_AccountId': 1443834.0, 'user_DisplayName': 'Abhijit', 'user_Reputation': 663.0, 'user_Views': 84.0, 'user_id': 1363086.0}}