我已遵循此answer以避免在hibernate查询中出现“路径异常”错误,但现在我正面临下面描述中给出的异常。
这是我的问题:
select lo from Transaction tr join tr.Loan lo on lo.loanId = tr.Loan.loanId
where
lo.loan_status = 'open' and
category = 'principal' and
date >= :fromDate and
date <= :toDate
order by date asc
错误:
org.hibernate.QueryException: could not resolve property: Loan of: model.core.Transaction[select lo from model.core.Transaction tr join tr.Loan lo on lo.loanId = tr.Loan.loanId where lo.loan_status = 'open' and category = 'principal' and date >= :fromDate and date <= :toDate order by date asc]
at org.hibernate.QueryException.generateQueryException(QueryException.java:120)
at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:218)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:155)
at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:764)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:495)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at utility.DbSessionManager.buildSessionFactory(DbSessionManager.java:16)
at utility.DbSessionManager.<clinit>(DbSessionManager.java:7)
at utility.LoanManager.getLoans(LoanManager.java:65)
at controller.LoanController.getLoan(LoanController.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)