Hi, I am stuck with this last piece of my application to be delivered yesterday :o). I have an object Report, which has a collection (map) of Involved objects. Each Involved object has a colleciton (map) of Violation objects. I am trying to get all the reports associated with a set of violations. This is the query I am trying to execute:
from ReportBean as report where report.involved.violation.id IN('1','3','5','7') order by report.id
I have tried to change to use element, composite-element but am still not understanding what is going on with the "net.sf.hibernate.QueryException: expecting 'elements' or 'indices' after: violation"
Please, any help will be greatly appreciated.
Thanks in advance,
Luis
Hibernate version:
hibernate-2.1
Mapping documents:
<hibernate-mapping schema="schema" package="edu.udel.Referrals">
<class name="ReportBean" table="report_table">
<id name="id" type="long">
<column name="id" not-null="true" unique="true" />
<generator class="sequence">
<param name="sequence">udpd_report_seq</param>
</generator>
</id>
<property name="caseNumber" type="string" not-null="true"/>
<property name="reportedDate" type="date"/>
<map name="involved" lazy="false" cascade="all" order-by="mapIndex">
<key column="reportId" />
<index column="mapIndex" type="string"/>
<one-to-many class="InvolvedBean" />
</map>
</class>
<class name="InvolvedBean" table="involved_table">
<id name="id">
<column name="id" unique="true" not-null="true" sql-type="char"
length="32" />
<generator class="uuid.hex"/>
</id>
<property name="fname" type="string"/>
<property name="lname" type="string"/>
<map name="violations" lazy="false" cascade="all" order-by="mapIndex">
<key column="involvedId" />
<index column="mapIndex" type="string"/>
<one-to-many class="ViolationsBean" />
</map>
</class>
<class name="ViolationsBean" table="violations_table">
<id name="id">
<column name="id" unique="true" not-null="true" sql-type="char"
length="32" />
<generator class="uuid.hex"/>
</id>
<property name="violationId" type="long"/>
<property name="charges" type="string"/>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
2004-10-26 10:12:36,757 [tcpConnection-6802-0] ERROR udpd - EXCEPTION: net.sf.hibernate.QueryException: expecting 'elements' or 'indices' after: violation [from ReportBean as report where report.involved.violation.id IN('1','3','5','7') order by report.id]
net.sf.hibernate.QueryException: expecting 'elements' or 'indices' after: violation [from edu.udel.judicial.beans.ReportBean as report where report.involved.violation.id IN('1','3','5','7') order by report.id]
at net.sf.hibernate.collection.CollectionPropertyMapping.toType(CollectionPropertyMapping.java:53)
at net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpressionParser.java:249)
at net.sf.hibernate.hql.PathExpressionParser.token(PathExpressionParser.java:123)
at net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:334)
at net.sf.hibernate.hql.WhereParser.doToken(WhereParser.java:366)
at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:251)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1554
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
from ReportBean as report where report.involved.violation.id IN('1','3','5','7') order by report.id
|