Hi!
I use this hql query:
select charge.id from Charge as charge
where
charge.patient.classification is not null
and
(select sum(entries.patientBalance) from charge.patient.entries as entries where entries.patientBalance is not null)=0
The "Charge" class is a sub-class of many classes (Entry, BaseAmount, Amount and Debit). It has a field named "patient", this is an another persistable class. The "patient" class has a field named "entries", this is a set of Entry-type objects.
The error is:
could not resolve property: patientBalance of: com.amkai.aes.generatedbeans.registration.Patient [...]
(full dump below)
I change the order of the conditions:
select charge.id from Charge as charge
where
(select sum(entries.patientBalance) from charge.patient.entries as entries where entries.patientBalance is not null)=0
and
charge.patient.classification is not null
By this case, the query runs.
I can convert both hql to sql.
I think, this is a bug. Maybe in HqlSqlWalker class. I think, the hibernate don't find the "patientBalance" field in the "Patient" class. But in my query, this field is in the "Entry" class!
Find someone this symptom also?
Hibernate version: 3.2.5.ga
Name and version of the database: MsSql 8.00.2039
The generated SQL (for the first hql query):
select charge0_.debit_id as col_0_0_
from ledger_charge charge0_
inner join ledger_debit charge0_1_ on charge0_.debit_id=charge0_1_.amount_id
inner join ledger_amount charge0_2_ on charge0_.debit_id=charge0_2_.baseamount_id
inner join ledger_baseamount charge0_3_ on charge0_.debit_id=charge0_3_.entry_id
inner join ledger_entry charge0_4_ on charge0_.debit_id=charge0_4_.id,
reg_patient patient1_
where
(
patient1_.classification_id is not null and charge0_4_.patient_id=patient1_.id
)and(
(select sum(entries3_.patientbalance) from reg_patient patient2_, ledger_entry entries3_ where charge0_4_.patient_id=patient2_.id and patient2_.id=entries3_.patient_id and ((entries3_.patientbalance is not null )))=0
)
The full exception dump:
org.hibernate.QueryException: could not resolve property: patientBalance of: com.amkai.aes.generatedbeans.registration.Patient [select charge.id from com.amkai.aes.generatedbeans.billingledger.Charge as charge
where
charge.patient.classification is not null
and
(select sum(entries.patientBalance) from charge.patient.entries as entries where entries.patientBalance is not null)=0
]
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1358)
at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:279)
at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:386)
at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:566)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:241)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:188)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1216)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.aggregateExpr(HqlSqlBaseWalker.java:2898)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.functionCall(HqlSqlBaseWalker.java:2346)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1963)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1825)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1394)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:553)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4049)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1690)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at com.amkai.common.extensions.hibernate.config.manager.SessionManager.execute(SessionManager.java:555)
at com.amkai.aes.servertools.hqlanalyzer.HqlAnalyzerController$10.actionPerformed(HqlAnalyzerController.java:270)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
|