-->
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: Hibernate, MySQL and variable assignment in queries
PostPosted: Tue Dec 09, 2008 1:41 pm 
Newbie

Joined: Sun Jun 24, 2007 10:24 am
Posts: 6
Hi.

Im trying to execute a query (using org.hibernate.Query.createSQLQuery()) that contains the following snibbet:

Code:
SELECT @rownum:=@rownum+1 rownum


Hibernate fails with:

Quote:
Space is not allowed after parameter prefix ':'


Is there really no way at all to turn off this bloody parameter parsing?

cheers,
mg


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2008 8:49 am 
Newbie

Joined: Sun Jun 24, 2007 10:24 am
Posts: 6
To those that may come later:

Seems to me that the only solution to this problem is to wrap the whole SQL statement into a stored procedure and then call it.

cheers,
mg


Top
 Profile  
 
 Post subject: Re: Hibernate, MySQL and variable assignment in queries
PostPosted: Mon May 14, 2012 11:33 pm 
Newbie

Joined: Mon May 14, 2012 11:20 pm
Posts: 1
Hi all,

Does any one know how to deal with this? The code below run successfully in MySQL but throwing exception in hibernate.org.hibernate.
QueryException: Space is not allowed after parameter prefix ':‘. I understand that := conflicts with the parameter settings.
Nevertheless, I can't simply create procedure/function since the query where clause is provided by the user.

This works in MySQL:
select row,der.plotno from(SELECT @row := @row + 1 as row, t.*FROM entry t, (SELECT @row := 0) r where plotno < 00009) as der where der.plotno = "00001"

Please advise.

Thanks,
Lanz


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.