0

I'm migrating my WildFly version from 8.1 (Hibernate 4.3.5) to 11.0 (Hibernate 5.1.10), and a new error just appears now:

Caused by: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags: [InformeMensalINR.aplicacoesEfetuadas, InformeMensalINR.recursosTransferidos]

The mapping is below and used to work fine on Hibernate 4:

@OneToMany(mappedBy="informeMensalINR",cascade=CascadeType.ALL,fetch=FetchType.EAGER,orphanRemoval=true) public List<RecursoTransferido> getRecursosTransferidos() { return recursosTransferidos; }

@OneToMany(mappedBy="informeMensalINR",cascade=CascadeType.ALL,fetch=FetchType.EAGER,orphanRemoval=true) public List<AplicacaoEfetuada> getAplicacoesEfetuadas() { return aplicacoesEfetuadas; }

Any ideas on why is this happening now? In WildFly 8 it works great. I didn't find anything in Hibernate JIRA related to this problem.

Valerio Lopes
  • 79
  • 1
  • 9

1 Answers1

1

I'm surprised why this worked in WildFly 8! Because Hibernate was never able to load two Lists eagerly because this produces a cartesian product.

Please find a detailed explanation here:

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

Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82
  • I think I realized what just happened. This piece of code is deployed on WildFly but is not called (it's used in a standalone app). In WFLY 8, probably this exception would be thrown only in runtime. WFLY 11 seems to check it in deployment time. – Valerio Lopes Dec 15 '17 at 13:56