Cannot get HQL queries to work in CB 3.1

75 views
Skip to first unread message

ecterpstra

unread,
Feb 6, 2012, 6:55:01 PM2/6/12
to col...@googlegroups.com
I have the latest stable release of Coldbox, and am trying to use the findAll() method.  I keep getting the same error after trying several different queries.

This works (returns an array of Member objects): 
rc.members = ormService.getAll(entityName = "Member");
rc.members = ormService.list("Member");

but this does not:
rc.members = ormService.getAll(entityName = "Member");
rc.members = ormService.findAll("from Member");

I get the following error:
Error Messages: Error while executing the Hibernate query.
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: Member near line 1, column 6 [from Member]    

...
coldfusion.orm.hibernate.HibernatePersistenceManager$QueryExecuteException: Error while executing the Hibernate query.
	at coldfusion.orm.hibernate.HibernatePersistenceManager.executeHQL(HibernatePersistenceManager.java:742)
	at coldfusion.orm.hibernate.HibernatePersistenceManager.executeQueryWithNamedParams(HibernatePersistenceManager.java:630)
	at coldfusion.orm.ORMUtils._executeQuery(ORMUtils.java:291)
	at coldfusion.orm.ORMUtils.executeQuery(ORMUtils.java:281) 
... and so on.

Luis Majano

unread,
Feb 6, 2012, 8:08:53 PM2/6/12
to col...@googlegroups.com
Hmm, not sure, on that one, can you post eh hql it builds
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

ecterpstra

unread,
Feb 7, 2012, 9:51:36 AM2/7/12
to col...@googlegroups.com
Sure, but I'm not entirely sure how to do that...

Luis Majano

unread,
Feb 7, 2012, 1:27:24 PM2/7/12
to col...@googlegroups.com
Hmm, not sure if Member is a keyword in HQL.
Try "from [Member]

On Tuesday, February 7, 2012 at 6:51 AM, ecterpstra wrote:

Sure, but I'm not entirely sure how to do that...

--

ecterpstra

unread,
Feb 7, 2012, 3:27:27 PM2/7/12
to col...@googlegroups.com
Yep, Member is an HQL keyword.  Changing Member.cfc to Memberz.cfc or Memb.cfc works just fine.  This is not ideal though, as I might run into more entities named the same as HQL keywords.

I've tried your suggestion for escaping Member, but still got the same error: 
unexpected token: [Member] near line 1

I also tried single quotes, curly braces, backslashes and model.Member (with all the escaping variations), and nothing seemed to work, other than to change the name of the CFC.

You think this might be a bug in CF ORM?

Klaas-Jan Winkel

unread,
Feb 7, 2012, 4:37:23 PM2/7/12
to col...@googlegroups.com
Maybe this is your answer?

--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org



--
"Surely you can't be serious": I am serious. And don't call me Shirley.
Reply all
Reply to author
Forward
0 new messages