下面是一个为特定用户提取问题的查询。我收到如下所述的控制台错误:org.hibernate.QueryException: fetch not allowed in subquery from-elements
我不确定如何去修复它,甚至不确定解释错误是从哪里来的。任何解决方案/指导都将受到赞赏。
String qw ="from StdQuestion as x"+
" join fetch x.stdTaxQstns as x1" +
" left join fetch x1.stdTax as x3"+
" where x1.id.taxCde in (select z.taxCde from StdTax as z "+
"join z.stdNaicsTaxes as z1 "+
"join z1.naicsMaster as z2 "+
"join z2.stdBusActivityNaicsMaps as z3 "+
"join z3.stdBusinessActivity as z4 "+
"where z4.businessActivityId in (:sbaId) "+
"and z4.exprnDt is null "+
"and z3.exprnDt is null) " +
" and x.exprnDt is null" +
" and x1.targetTableNm is null" +
" and upper(x.rspnType) != upper('SUP') " +
" and x.custTypeCde in (:custypeCode)" +
" and x.qstnCategoryCde = :qstncode " +
"and x1.id.taxCde not in (select st.taxCde"
+ " from CustSiteAcct as csa "
+ " left join fetch csa.id as x2 "
+ " left join fetch csa.customer as c "
+ " left join fetch csa.applicableTax as at "
+ " left join fetch stf.stdTax as st "
+ " left join fetch at.stdTaxForm as stf"
+ " where csa.id.cusAcctNbr = at.acctNbr"
+ " and x2.cusAcctNbr = :acctNbr"
+ " and at.CustSiteAcct.id = x2"
+ " and at.acctNbr = c.acctNbr"
+ " and at.siteNbr = csa.id.siteNbr"
+ " and at.exprnDt is null"
+ " and c.custAcctEndDt is null"
+ " and csa.id.cusAcctNbr = :acctNbr)"
+ "order by x1.sortSeqNbr"
;
Query q = session.createQuery(qw);
q.setParameterList("sbaId", sbaIds);
q.setParameterList("custypeCode", companyType != null ? new Object[] { "ALL", companyType } : new Object[] { "ALL"} );
q.setParameter("qstncode", "T");
q.setParameter("acctNbr", acctNbr);
return q.list();
}
1条答案
按热度按时间n6lpvg4x1#
我遇到了一个类似的问题。错误信息是由下面的行(和类似的行)引起的:
看起来子查询不允许有“fetch”。刚刚删除了它:
我认为子查询总是渴望的,所以“fetch”在这里是不必要的。