gavin wrote:
Current CVS supports aliases.
I have just tried it with Beta 1 and still didn't get HQL to work. Here's what I ran:
String hql = "delete from gov.va.med.domain.model.PathologyIcdDiagnoses object where object.pathology.patient.id = :userIdSeq";
logger.debug("Executing HQL: " + hql);
Query query = getSession().createQuery( hql );
query.setString( "userIdSeq" , userIdSeq.toString());
int count = query.executeUpdate();
and here's what I got:
09:36:19,506 DEBUG PathologiesDAO:84 - Executing HQL: delete from gov.va.med.domain.model.PathologyIcdDiagnoses object where object.pathology.patient.id = :userIdSeq
<Jul 22, 2005 9:36:19 AM EDT> <Error> <org.hibernate.hql.PARSER> <000000> <line 1:59: unexpected token: object>
09:36:20,077 ERROR PARSER:111 - line 1:59: unexpected token: object
java.lang.NoSuchMethodError: org.hibernate.hql.antlr.HqlBaseParser.recover(Lantlr/RecognitionException;Lantlr/collections/impl/BitSet;)V
at org.hibernate.hql.antlr.HqlBaseParser.optionalFromTokenFromClause(HqlBaseParser.java:400)
at org.hibernate.hql.antlr.HqlBaseParser.deleteStatement(HqlBaseParser.java:259)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:148)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:231)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:150)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:100)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:459)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:902)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:883)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89)
--------------------------------------------------------------
Running this HQL delete:
"delete from gov.va.med.domain.model.PathologyIcdDiagnoses where pathology.patient.id = :userIdSeq"
(PathologyIcddiagnoses has a many-to-one association with Pathology and Pathology has a many-to-one with Patient) I got this exception:
09:40:14,454 DEBUG PathologiesDAO:84 - Executing HQL: delete from gov.va.med.domain.model.PathologyIcdDiagnoses where pathology.patient.id = :userIdSeq
org.hibernate.QueryException: could not resolve property: patient of: gov.va.med.domain.model.PathologyIcdDiagnoses [delete from gov.va.med.domain.model.PathologyIcdDiagnoses where pathology.patient.id = :userIdSeq]
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.BasicEntityPersister.toType(BasicEntityPersister.java:1131)
at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:274)
at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:353)
at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:517)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:217)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:172)
at org.hibernate.hql.ast.tree.DotNode.resolveFirstChild(DotNode.java:139)
at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:394)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4315)
Mapping document for Pathology:
<!-- bi-directional many-to-one association to Patient -->
<many-to-one
name="patient"
class="gov.va.med.domain.model.Patient"
not-null="true"
>
<column name="USER_ID_SEQ" />
</many-to-one>