-->
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.  [ 8 posts ] 
Author Message
 Post subject: Incorrect syntax near the keyword as
PostPosted: Mon Oct 24, 2005 10:44 am 
Newbie

Joined: Fri Jun 10, 2005 5:11 am
Posts: 7
Hi,

We are using 3.0 and when excuting a subquery using the DetachedCriteria, the query generated looks fine.

But the sub-query has the keyword [b]as y0_[/b] and sybase doesn't like that in a subquery.

Does anyone know of a fix to stop this problem.

the generated query is as below.

select id, raw_id from table_a this_1_
where this_1_.raw_id in
(select this0__.raw_id [i][b]as y0_[/b][/i] from table_a this0__ where this0__.id=200245319)

Thank you

Ravi


Top
 Profile  
 
 Post subject: Re: Incorrect syntax near the keyword as
PostPosted: Mon Oct 24, 2005 10:49 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Are you using the Sybase Dialect ?

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: Re: Incorrect syntax near the keyword as
PostPosted: Mon Oct 24, 2005 10:52 am 
Newbie

Joined: Fri Jun 10, 2005 5:11 am
Posts: 7
[quote="pksiv"]Are you using the Sybase Dialect ?[/quote]

Yes am using SybaseDialect.


Top
 Profile  
 
 Post subject: Re: Incorrect syntax near the keyword as
PostPosted: Mon Oct 24, 2005 10:53 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
ukuser wrote:
pksiv wrote:
Are you using the Sybase Dialect ?


Yes am using SybaseDialect.


What is the exception you are getting. Can you show the Stacktrace ?

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: Re: Incorrect syntax near the keyword as
PostPosted: Mon Oct 24, 2005 10:55 am 
Newbie

Joined: Fri Jun 10, 2005 5:11 am
Posts: 7
com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near the keyword 'as'.

at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2636)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1996)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187)
at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1537)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1522)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:72)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:118)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1233)
at org.hibernate.loader.Loader.doQuery(Loader.java:370)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
at org.hibernate.loader.Loader.doList(Loader.java:1557)
at org.hibernate.loader.Loader.list(Loader.java:1540)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:113)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1254)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 08, 2006 10:23 am 
Newbie

Joined: Thu Jun 08, 2006 7:27 am
Posts: 1
Location: Rome - Italy
Hi, i'm using the JTDS driver, and having exactly the same problem...

Code:
2006-06-08 15:12:29,750 ERROR org.springframework.web.servlet.DispatcherServlet  - Could not complete request
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.USER_APP
_USERNAME as USER1_0_, this_.USER_APP_PASSWORD as USER2_0_0_, this_.USER_APP_FIRST_NAME as USER3_0_0_, this_.USER_APP_LAST_NAME as USER4_0_0_, this_.USER_A
PP_EMAIL as USER5_0_0_, this_.USER_APP_SECURITY_ANSWER as USER6_0_0_, this_.USER_APP_BIRTH_DATE as USER7_0_0_, this_.USER_APP_ROLE as USER8_0_0_, this_.USE
R_APP_UNEMPLOYMENT as USER9_0_0_, this_.USER_APP_PARENT_UNEMPL as USER10_0_0_, this_.USER_APP_RELATIVE_NAME as USER11_0_0_, this_.USER_APP_VACANCY_NUMBER a
s USER12_0_0_, this_.USER_APP_UNORGANIZATION as USER13_0_0_, this_.USER_APP_QUESTION as USER14_0_0_, this_.USER_APP_NATIONALITY as USER15_0_0_, this_.USER_
APP_SEC_NATIONALITY as USER16_0_0_, this_.USER_APP_TITLE as USER17_0_0_, this_.USER_APP_GENDER as USER18_0_0_, this_.USER_APP_MARITAL_STATUS as USER19_0_0_
, this_.USER_APP_RELAT_PARENT as USER20_0_0_, this_.USER_APP_NAT_YEARS_EXP as USER21_0_0_, this_.USER_APP_INT_YEARS_EXP as USER22_0_0_, this_.USER_APP_MEMB
ERSHIP as USER23_0_0_, this_.USER_APP_PUBLICATIONS as USER24_0_0_, this_.USER_APP_OTHER_INFO as USER25_0_0_, this_.USER_APP_SUBMIT_DATE as USER26_0_0_, thi
s_.USER_APP_PHFSTATUS as USER27_0_0_ from T_USER_APPLICANT this_ where this_.USER_APP_SUBMIT_DATE is not null and this_.USER_APP_USERNAME in (select this0_
_.LANGUAGE_USER_USER as y0_ from T_LANGUAGE_USER this0__ where this0__.LANGUAGE_USER_LANGUAGE=?)]; SQL state [37000]; error code [102]; Incorrect syntax ne
ar ','.
; nested exception is java.sql.SQLException: Incorrect syntax near ','.

java.sql.SQLException: Incorrect syntax near ','.

        at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
        at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
        at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
        at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628)
        at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:418)
        at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:693)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
        at org.hibernate.loader.Loader.doQuery(Loader.java:391)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
        at org.hibernate.loader.Loader.doList(Loader.java:1593)
        at org.hibernate.loader.Loader.list(Loader.java:1577)
        at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322)
        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
        at org.springframework.orm.hibernate3.HibernateTemplate$35.doInHibernate(HibernateTemplate.java:944)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:358)
        at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:934)
        at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:927)
        at org.ifad.webroster.dao.HibernateLogging.findApplicants(HibernateLogging.java:168)
        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:324)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
        at $Proxy46.findApplicants(Unknown Source)
        at org.ifad.webroster.service.LoggingService.findApplicants(LoggingService.java:205)
        at org.ifad.webroster.web.controllers.administration.FindCandidatesController.referenceData(FindCandidatesController.java:51)
        at org.springframework.web.servlet.mvc.AbstractFormController.showForm(AbstractFormController.java:538)
        at org.springframework.web.servlet.mvc.SimpleFormController.showForm(SimpleFormController.java:193)
        at org.springframework.web.servlet.mvc.SimpleFormController.showForm(SimpleFormController.java:172)
        at org.springframework.web.servlet.mvc.AbstractFormController.showNewForm(AbstractFormController.java:321)
        at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:261)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:139)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:347)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.ifad.webroster.web.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:89)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 1:40 am 
Newbie

Joined: Thu Sep 14, 2006 1:53 am
Posts: 2
Has anyone found a fix for this?

Just to clarify, in Sybase, you can't give an alias to the column in a subquery.

To paraphrase Ravi's SQL, this is illegal in Sybase;

select id, raw_id from table_a this_1_
where this_1_.raw_id in
(select this0__.raw_id as y0_
from table_a this0__
where this0__.id=200245319)

but this (ie without the y0_) would be OK;

select id, raw_id from table_a this_1_
where this_1_.raw_id in
(select this0__.raw_id as
from table_a this0__
where this0__.id=200245319)

Guenther


Top
 Profile  
 
 Post subject: Re: Incorrect syntax near the keyword as
PostPosted: Sun Apr 06, 2008 9:31 pm 
Newbie

Joined: Thu Sep 14, 2006 1:53 am
Posts: 2
Workaround:
detachedCriteria.setProjection(Projections.sqlProjection("1", null, null));


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.