org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags

前端 未结 7 837
南笙
南笙 2020-12-04 20:07

Following is my code Here I am using multiple lists to fetch data from database. On fetching data from hql query it is showing exception.

Pojo Class

         


        
7条回答
  •  眼角桃花
    2020-12-04 20:48

    I find using @PostLoad annotated method in the entity most useful, I'd do something like

    @PostLoad
    public void loadCollections(){
         int s1 = productReplacements.size();
         int s2 = billProductList.size();
    }
    

    this way I'm able to fine control the eager loading and initialization of collections in the same transaction that loaded the entity.

提交回复
热议问题