Hi All:
I needed your help!! I am using hibernate 3.3.2. From the following hql code: ContactCustomerDAOImpl.java: public class ContactCustomerDAOImpl implements ContactCustomerDAO{
public List findContactCustomer() { List allCustomers = this.hibernateTemplate.executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { String queryString = "SELECT a.customerId, a.nameTxt, a.roleName, " + "a.emailAddressText, a.faxNumber,a.workPhoneExt,a.workPhoneNumber " + "c.customerId, c.companyName,c.iataNumber, " + "c.address,c.city,c.provinceStateId,b.provinceStateCode " + "c.postal, c.fax " + " FROM Contact a LEFT OUTER JOIN a.customer c " + "LEFT OUTER JOIN c.provinceState where a.contactId=1450 " + "and c.deletedFlag=0 " + "and a.contactDeletedFlag=0"; Query query = session.createQuery(queryString); return query.list();
} }); return allCustomers; } }
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(HqlBaseParser.java:3520) at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3216) at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3098) at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2818) at org.hibernate.hql.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:570) at org.hibernate.hql.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2586) at org.hibernate.hql.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2449) at org.hibernate.hql.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2413) at org.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2331) at org.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2296) at org.hibernate.hql.antlr.HqlBaseParser.expression(HqlBaseParser.java:2082) at org.hibernate.hql.antlr.HqlBaseParser.aliasedExpression(HqlBaseParser.java:2249) at org.hibernate.hql.antlr.HqlBaseParser.selectedPropertiesList(HqlBaseParser.java:1462) at org.hibernate.hql.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:1365) at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1106) at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:702) at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296) at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:274) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1293) at $Proxy15.createQuery(Unknown Source) at com.dao.impl.ContactCustomerDAOImpl$1.doInHibernate(ContactCustomerDAOImpl.java:28) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419) at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343) at com.dao.impl.ContactCustomerDAOImpl.findContactCustomer(ContactCustomerDAOImpl.java:17) at com.dao.impl.junit.TestContactCustomerDAOImpl.testContactCustomer(TestContactCustomerDAOImpl.java:14) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:243) at junit.framework.TestSuite.run(TestSuite.java:238) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
This was suppose to be the Oracle equivalent sql code for the hql code above: Select A.CUSTOMER_ID, A.NAME_TXT, A.ROLE_NM, A.EMAIL_ADDRESS_TXT, A.FAX_NBR, A.WORK_PHONE_EXT, A.WORK_PHONE_NBR, C.NBR_SQ, C.COMPANY_NM, c.iata_nbr,C.ADDRESS_TXT, C.CITY_NM, C.PROVINCE_STATE_ID, B.PROVINCE_STATE_CD, C.POSTAL_CD,C.FAX_NBR from contact a LEFT OUTER JOIN customer c ON A.CUSTOMER_ID = C.NBR_SQ LEFT OUTER JOIN ct_common_owner.province_state b on B.NBR_SQ = C.PROVINCE_STATE_ID WHERE A.NBR_SQ = 1450 and C.DELETED_FLG = 0 and A.DELETED_FLG = 0
Any hint or help would be greatly appreciated it!!
|