-->
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: NullPointerException trying to use Collection in ORDER BY
PostPosted: Sun Aug 08, 2004 3:17 pm 
Beginner
Beginner

Joined: Tue Dec 09, 2003 5:59 pm
Posts: 25
Location: Los Angeles
I'm getting a NullPointerException from PathExpressionParser when trying to issue the following HQL query:

"select o.id, o.name, o.phones[0].areaCode, o.phones[0].exchange from Individual o where o.source = 'foo' order by o.name, o.phones[0].areaCode, o.phones[0].exchange"

I'm guessing that this is happening because Hibernate doesn't understand how to follow the collection references in the order by clause. Is that correct? If so, are there any plans to support this? If not, any idea what I might be doing wrong? Thanks.

Hibernate version: 2.1.5

Full stack trace of any exception that occurs:
net.sf.hibernate.QueryException: Incorrect query syntax [select o.id, o.name, o.phones[0].areaCode, o.phones[0].exchange from com....Individual o where o.source = 'foo' order by o.name, o.phones[0].areaCode, o.phones[0].exchange]
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:166)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)
at
... 5 more
Caused by: java.lang.NullPointerException
at net.sf.hibernate.hql.PathExpressionParser.getWhereColumn(PathExpressionParser.java:375)
at net.sf.hibernate.hql.OrderByParser.token(OrderByParser.java:31)
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)
... 13 more


Name and version of the database you are using: Oracle 9


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 3:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
That is correct.

To workaround, do the join in the from clause, and use the index() function in the where clause.

perhaps this is something we might be able to support when we get the new query parser


Top
 Profile  
 
 Post subject: Thanks Gavin
PostPosted: Sun Aug 08, 2004 4:49 pm 
Beginner
Beginner

Joined: Tue Dec 09, 2003 5:59 pm
Posts: 25
Location: Los Angeles
Your workaround seems to be working. Thanks for the quick response.


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.