Di seguito è riportato il mio codice Qui sto utilizzando più elenchi per recuperare i dati dal database. Durante il recupero dei dati dalla query hql sta mostrando un'eccezione.org.hibernate.loader.MultipleBagFetchException: impossibile prelevare contemporaneamente più buste
Pojo Classe
public class BillDetails implements java.io.Serializable {
private Long billNo;
// other fields
@LazyCollection(LazyCollectionOption.FALSE)
private List<BillPaidDetails> billPaidDetailses = new ArrayList<BillPaidDetails>();
private Set productReplacements = new HashSet(0);
@LazyCollection(LazyCollectionOption.FALSE)
private List<BillProduct> billProductList = new ArrayList<BillProduct>();
//getter and setter
}
file di hmb.xml
<class name="iland.hbm.BillDetails" table="bill_details" catalog="retail_shop">
<id name="billNo" type="java.lang.Long">
<column name="bill_no" />
<generator class="identity" />
</id>
<bag name="billProductList" table="bill_product" inverse="true" lazy="false" fetch="join">
<key>
<column name="bill_no" not-null="true" />
</key>
<one-to-many class="iland.hbm.BillProduct" />
</bag>
<bag name="billPaidDetailses" table="bill_paid_details" inverse="true" lazy="false" fetch="select">
<key>
<column name="bill_no" not-null="true" />
</key>
<one-to-many class="iland.hbm.BillPaidDetails" />
</bag>
<set name="productReplacements" table="product_replacement" inverse="true" lazy="false" fetch="join">
<key>
<column name="bill_no" not-null="true" />
</key>
<one-to-many class="iland.hbm.ProductReplacement" />
</set>
</class>
interrogazione HQL
String hql = "select distinct bd,sum(bpds.amount) from BillDetails as bd "
+ "left join fetch bd.customerDetails as cd "
+ "left join fetch bd.billProductList as bpd "
+ "left join fetch bpd.product as pd "
+"left join fetch bd.billPaidDetailses as bpds "
+ "where bd.billNo=:id "
+ "and bd.client.id=:cid ";
sto cercando seguente query per recuperare i dati dal database, ma questo sta mostrando org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
Come risolvere e questo
Hai provato cambiare le vostre liste al set? – JamesB
Questo articolo può aiutarti: http://blog.eyallupu.com/2010/06/hibernate-exception-simultaneously.html – JamesB
Qual è il nome della proprietà id univoca su BillProduct? – JamesB