-->
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: setMaxResults throwing SQLGrammarException
PostPosted: Thu Aug 10, 2006 3:30 am 
Beginner
Beginner

Joined: Fri Jun 16, 2006 7:47 am
Posts: 27
I am using the DB2 dialect.
While using the Criteria api and putting the setMaxResults.
It is throwing SQLGrammarException.

List reasonCodeTypeCriteria = session.createCriteria(ReasonCodeType.class)
.add(Expression.eq("reasonCodeTypePk.reasonCode","DRE"))
.setMaxResults(10)
.list();



The corresponding sql generated is wrong:
It is:
[b]select * from ( [/b]select rownumber() over() as rownumber_, this_.EXCPN_REASON_CD as EXCPN1_0_, this_.EXCPN_TYPE_CD as EXCPN2_0_, this_.EXCPN_REASON_CD as EXCPN1_8_0_, this_.EXCPN_TYPE_CD as EXCPN2_8_0_ from A1PRD.EXCPN_REASON_TYPE this_ where this_.EXCPN_REASON_CD=? ) as temp_ where rownumber_ <= ?

An unexpected token "(" was found following "". Expected tokens may include: ", FROM INTO ". SQLSTATE=42601

Any help would be appreciated.
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 1:23 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
Re-check your dialect usage -- "FETCH FIRST x ROWS ONLY" is the DB2 limiting clause not "rownumber_ <= ?"

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 18, 2006 3:26 pm 
Beginner
Beginner

Joined: Thu Aug 31, 2006 2:31 pm
Posts: 25
Location: USA
Hi All,
This must be related to your dialect .Please look at the following link to get your right dialect class and replace it in your properties file or where ever you specified your hibernate.dialect properties.

http://www.hibernate.org/hib_docs/v3/ap ... mmary.html


Note - I was getting the SQL generated like limiting clause not "rownumber_ <= ?" before I switch my dialect from org.hibernate.dialect.DBDialect to org.hibernate.dialect.DB2390Dialect.
Thanks to curtis for pointing this out.
Regards,
Vinodh

_________________
I am using a shitty e-mail filtering system that caused a lot of bounces for the admin of this forum. I need to turn on my brain next time and update my e-mail address.


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.