These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: expecting 'elements' or 'indices'
PostPosted: Tue Oct 26, 2004 10:36 am 
Newbie

Joined: Tue Oct 26, 2004 10:25 am
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 4:10 pm 
Newbie

Joined: Wed Mar 24, 2004 11:13 am
Posts: 15
Location: Norcross, GA
Is it violation or violations?
The mapping says "violations" while the query uses "violation"
Could that be the problem?

_________________
Madhu


Top
 Profile  
 
 Post subject: expecting 'elements' or 'indices'
PostPosted: Wed Oct 27, 2004 9:38 am 
Newbie

Joined: Tue Oct 26, 2004 10:25 am
Posts: 2
Thanks for the tip, but it still didn't work. Because of the time constraint on this application I ended up using a "basic" sql query:

select report from ReportBean report, InvolvedBean involved, ViolationsBean violation where report.id = involved.reportId and violation.involvedId = involved.id and violation.violationId in (1,3) order by report.id

I would really like to know what the error on the original query is though. If you, someone else out there have any more ideas I would like to keep trying.

Thanks,
Luis


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.