This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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: 48
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: 18541

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

Joined: Jan 17, 2008
Posts: 2274

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
Similar Threads
servletunit.struts nullpointer problem
Hibernate - Query Issues With Many-To-One Relationships
TransientObjectException while fetching data.
Hibernate Desing issue
How to insert DateTime with HQL