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

前端 未结 7 849
南笙
南笙 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:53

    I used the new annotation @OrderColumn instead of @IndexColumn (deprecated see: https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/annotations/IndexColumn.html) and it works now.

    Annotate one of the collections with @OrderColumn e.g.

    @ManyToMany(cascade = CascadeType.ALL)
    @OrderColumn
    private List addresses = Lists.newArrayList();
    
    @Builder.Default
    @ManyToMany(cascade = CascadeType.ALL)
    private List bankAccounts = Lists.newArrayList();
    

提交回复
热议问题