当Query to Parent,Child也被提取时,Hibernate

时间:2015-09-22 17:53:33

标签: java json hibernate

在我的应用程序中,存在具有一对多关系的实体。当我查询父项时,孩子们也会被提取。我想只获取父级。我尝试将fetchType添加为Lazy,但它仍会抓取孩子。实体如下:

  

家长实体

@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> instituteInfoDetails = new HashSet<InstituteInfoDetails>();

    @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> getInstituteInfoDetails()
    {
        return instituteInfoDetails;
    }

    public void setInstituteInfoDetails(Set<InstituteInfoDetails> 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 "";
        }
    }

}
  

儿童实体

@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> getInstituteInfoMatserList()
    {
        logger.info("Listing Institute Master");
        Session session = sessionFactory.getCurrentSession();
        Query query = session.createQuery("select info from InstituteInfoMaster info");

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

日志

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=?

1 个答案:

答案 0 :(得分:0)

  1. 确保在记录根实体时,其toString()实现不会显式或隐式迭代子集合:

    logger.info("List : " + instituteInfoMaster);
    
  2. 如果Hibernate Session仍处于打开状态,并且您尝试将根序列化为JSON,则在访问子集合时,将初始化它,并且还将获取每个关联的子节点。要证明这一点,请尝试将@JsonIgnore添加到子集合中并再次检查。

  3. 尝试在儿童系列上添加@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE),让2nd level collection cache为您处理。