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.  [ 3 posts ] 
Author Message
 Post subject: FETCH first n rows only
PostPosted: Thu Jun 02, 2005 7:42 pm 
Beginner
Beginner

Joined: Fri May 21, 2004 12:21 pm
Posts: 22
Location: Sacramento CA, USA
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0.4

I am using DB2 8x. we impl. the getLimitString as follows, it worked in 2.16 and also is working in the classic parser. but it is not working with new HQL parser. Does any one have this issue?? can any one direct me what to do?
Thanks
Perumal


public String getLimitString( String sql,
int hasOffset,
int limit )
{
return new StringBuffer( sql.length( ) + 40 )
.append( sql )
.append( " FETCH first " )
.append( limit )
.append( " rows only " )
.toString( );
}



Name and version of the database you are using: DB2 8x

The generated SQL (show_sql=true):select lct FROM LogicalCollectionTransactionBO AS lct FETCH first 10 rows only
Caused by: line 1:561: unexpected token: FETCH
at org.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:3057)
at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:2758)
at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:2640)
at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2365)
at org.hibernate.hql.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:471)
at org.hibernate.hql.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2154)
at org.hibernate.hql.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2017)
at org.hibernate.hql.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:1981)
at org.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:1899)
at org.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:1864)
at org.hibernate.hql.antlr.HqlBaseParser.expression(HqlBaseParser.java:1632)
at org.hibernate.hql.antlr.HqlBaseParser.orderElement(HqlBaseParser.java:1672)
at org.hibernate.hql.antlr.HqlBaseParser.orderByClause(HqlBaseParser.java:870)
at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:648)
at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:260)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:150)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:209)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 3:01 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Why don't you use the following?

Code:
Query q = sess.createQuery("...");
q.setFirstResult(...);
q.setMaxResults(40);
List result = q.list();

See documentation for more information.

Best regards,
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 12:09 pm 
Beginner
Beginner

Joined: Fri May 21, 2004 12:21 pm
Posts: 22
Location: Sacramento CA, USA
Thanks for the suggestion. I will try that

Perumal


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