This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Error: unexpected token: c Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Error: unexpected token: c" Watch "Error: unexpected token: c" New topic

Error: unexpected token: c

John Smith
Ranch Hand

Joined: Aug 21, 2004
Posts: 49
Hi All:

I needed your help!! I am using hibernate 3.3.2.
From the following hql code:

I get the following error:
hibernate error:
10:33:28,949 DEBUG ErrorCounter:51 - line 1:110: unexpected token: c
line 1:110: unexpected token: c
at org.hibernate.hql.antlr.HqlBaseParser.atom(
at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(
at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(
at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(
at org.hibernate.hql.antlr.HqlBaseParser.concatenation(
at org.hibernate.hql.antlr.HqlBaseParser.relationalExpression(
at org.hibernate.hql.antlr.HqlBaseParser.equalityExpression(
at org.hibernate.hql.antlr.HqlBaseParser.negatedExpression(
at org.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(
at org.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(
at org.hibernate.hql.antlr.HqlBaseParser.expression(
at org.hibernate.hql.antlr.HqlBaseParser.aliasedExpression(
at org.hibernate.hql.antlr.HqlBaseParser.selectedPropertiesList(
at org.hibernate.hql.antlr.HqlBaseParser.selectClause(
at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(
at org.hibernate.hql.antlr.HqlBaseParser.queryRule(
at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(
at org.hibernate.hql.antlr.HqlBaseParser.statement(
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(
at org.hibernate.engine.query.HQLQueryPlan.<init>(
at org.hibernate.engine.query.HQLQueryPlan.<init>(
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(
at org.hibernate.impl.AbstractSessionImpl.createQuery(
at org.hibernate.impl.SessionImpl.createQuery(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(
at $Proxy15.createQuery(Unknown Source)
at com.dao.impl.ContactCustomerDAOImpl$1.doInHibernate(
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(
at com.dao.impl.ContactCustomerDAOImpl.findContactCustomer(
at com.dao.impl.junit.TestContactCustomerDAOImpl.testContactCustomer(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at junit.framework.TestCase.runTest(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

This was suppose to be the Oracle equivalent sql code for the hql code above:

Any hint or help would be greatly appreciated it!!
Paul Clapham

Joined: Oct 14, 2005
Posts: 19754

Line 12 looks fishy to me. Shouldn't OUTER JOIN be followed by a table name?
Jayesh A Lalwani
Saloon Keeper

Joined: Jan 17, 2008
Posts: 2682

First of all, what's on column 110 of that query? The stack trace is pointing you to where the problem is. It might help to look at it

Secondly, instead of

why don't you just do

Chandrasekar Venkatraman

Joined: Aug 23, 2010
Posts: 22


Error lies in this line

"c.address,,c.provinceStateId,b.provinceStateCode " +
"c.postal, c.fax " +

See that there's no comma after b.provinceStateCode .
Thjis is the issue. Query looks correct.

Learn to live.. Live to learn..
I agree. Here's the link:
subject: Error: unexpected token: c
It's not a secret anymore!