-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL: Incorrect syntax near
PostPosted: Thu Apr 28, 2005 1:36 pm 
Newbie

Joined: Mon May 03, 2004 11:49 am
Posts: 3
Hi, I'm having a problem with an hql query .
I'm using a Sybase database, and I'm trying to do an hql query to the database .
First, the query has about 10 nestested 'AND' & 'OR' criterias, this query work ok, but when I tried the query with about 300 nested 'AND' and 'OR', I've got the next exception (this is a fragment):

Caused by: com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near '='.

at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2796)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2126)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:220)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:203)
at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1578)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1563)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:85)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:88)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
... 43 more
com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near '='.

at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2796)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2126)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:220)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:203)
at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1578)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1563)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:85)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:88)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)


The query worked ok with a few conditions, but when I incremented them, it started to fail. I don't think that the sintax is wrong, because it's generated in a for cycle, and when the cycles are short (about 10 cycles) , the query works fine. When I put 300 cycles, throws the exception.

I've tried to put another dialect for Sybase, but it doesn't work. ¿Anybody know something about it?

This is the query (It's just a part of it):

select bookbus0_.objectId_id as objectId1_, bookbus0_.bookNumber as accountN2_, bookbus0_.type_sel_code as type_sel3_, bookbus0_.ownerId_id as ownerId_id, bookbus0_.reference as reference, bookbus0_.status_sel_code as status_s6_, bookbus0_.externalCode as external7_, bookbus0_.name as name, bookbus0_.office as office, bookbus0_.library as library from service bookbus0_ where (((bookbus0_.!='1427000041' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000206' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000367' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000358' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000935' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000057' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434001512' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000360' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434001141' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000999' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1341564894' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0002' ))OR((bookbus0_.library!='0001' )))))AND((((bookbus0_.bookNumber!='1434001840' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0001' )))))AND((((bookbus0_.bookNumber!='0222001840' ))OR(((bookbus0_.type_sel_code!='09' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0001' )))))AND((((bookbus0_.bookNumber!='1434000014' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0001' )))))AND((((bookbus0_.bookNumber!='1434000388' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000564' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222000032' ))OR(((bookbus0_.type_sel_code!='09' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001512' ))OR(((bookbus0_.type_sel_code!='09' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000412' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000005' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000403' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434000397' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1234567890' ))OR(((bookbus0_.type_sel_code!='02' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1234567890' ))OR(((bookbus0_.type_sel_code!='02' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0001' )))))AND((((bookbus0_.bookNumber!='1427000041' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0001' )))))AND((((bookbus0_.bookNumber!='1434000379' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1877777990' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0001' )))))AND((((bookbus0_.bookNumber!='2410000581' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0001' )))))AND((((bookbus0_.bookNumber!='1434005639' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222002542' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='1434005620' ))OR(((bookbus0_.type_sel_code!='08' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND
.........................................
((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001549' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001530' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001521' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001512' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001503' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001497' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001488' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001479' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001460' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001442' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001433' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001682' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001354' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((((bookbus0_.bookNumber!='0222001202' ))OR(((bookbus0_.type_sel_code!='06' ))OR(((bookbus0_.office!='0001' ))OR((bookbus0_.library!='0094' )))))AND((bookbus0_.bookNumber like '%' )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 2:43 pm 
Newbie

Joined: Tue Apr 26, 2005 3:06 pm
Posts: 14
Location: Vitória - ES - Brasil
Quote:
Caused by: com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near '='.



Normalmente estes erros costumam ser resultados de HQLs mal formatados.
Provavelmente você se perdeu na hora de montá-lo.
Verifique o HQL que será passado para o hibernate, e confira se não há nenhum erro!


[]`s

_________________
Roberto Marconi


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