-->
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: Moving away from v2 to v3.1.2. Query language not supported!
PostPosted: Tue Nov 07, 2006 7:07 pm 
Beginner
Beginner

Joined: Tue Feb 08, 2005 1:29 pm
Posts: 20
Hibernate version: v3.1.2

That piece of code was working with v2, but does not work anymore as I just migrated to v3.1.2. I have the following exception with the code below: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: limit near line 1, column 165 [select o from com.etil.sudetp.business.manager.offerbook.impl.OfferBookMarketOverview as o where o.homeFeatured=:feat AND o.productState=:prodState order by rand() limit 5]

StringBuffer rand = new StringBuffer();

if (random == true) {
rand.append(" order by rand() limit 5");
}

Query offerMarkets;
if (catId == Global.ROOT_PRODUCT_CATEGORY_ID) {
offerMarkets = t.session
.createQuery("select o from OfferBookMarketOverview as o where o.homeFeatured=:feat AND o.productState=:prodState"+ rand);
offerMarkets.setString("feat", Global.YES);
offerMarkets.setString("prodState", ProductState.TRADE_STATE);
}

for (Iterator it = offerMarkets.iterate(); it.hasNext();) {
OfferBookMarketOverview marketOverview = (OfferBookMarketOverview) it.next();


I have tried with setMaxResults(5), but I have another exception as well: org.hibernate.exception.SQLGrammarException: could not execute query using iterate.
What can I use then?

Any help will be very much appreciated.

Cheers.
DvJ


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 7:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I think you will find its the 'order by rand()'. In V2 it would pass items though if it did not know about them, while V3 is much more careful (as the parser is a better approach). You might need to go to a native query to solve this.


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.