Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » setMaxResults() doesn't work with MySql - sql syntax error
setMaxResults() doesn't work with MySql - sql syntax error [message #550659] Wed, 04 August 2010 05:41 Go to next message
moritz du is currently offline moritz du
Messages: 98
Registered: February 2010
Member
i am using mysql(connector 5.1.12 and db 5.1.47) in conjunction with eclipselink 2.0.1. nearly all went fine so far but now i tried to limit a select statement's output with q.setMaxResults(x) but this yields a very strange Query:

"SELECT `Id` AS `Id`1, `column2` AS `column2`2, ... FROM table LIMIT 0, 5"

why "as `ID`1" - the error message says "syntax error near '1'"

Without the setMaxResults the syntax is right:
"SELECT `Id`, `column2`, ... FROM Table"

And with derby embedded driver both work. So it is a "EclipseLink with MySql" Problem?!
The settings in peristence.xml are nearly the same. the only differences are logging and "<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />"
Re: setMaxResults() doesn't work with MySql - sql syntax error [message #550675 is a reply to message #550659] Wed, 04 August 2010 06:48 Go to previous messageGo to next message
moritz du is currently offline moritz du
Messages: 98
Registered: February 2010
Member
seem to be fixed in eclipselink 2.1.0 Smile

now the generated limit syntax is:

"SELECT `Id` AS a1, `column2` AS a2, ... FROM table LIMIT 0, 5"

but why it generates "as a1" (the 'as') if setMaxResult is used?
Re: setMaxResults() doesn't work with MySql - sql syntax error [message #550913 is a reply to message #550675] Wed, 04 August 2010 15:48 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Good that it is fixed. Seems like it was an issue with "quoted" (deliminated) column names.

The alias is used because the result set must be flattened to process the limit, and there could be duplicate column names if multiple tables were selected.


James : Wiki : Book : Blog : Twitter
Previous Topic:Merge resets new data
Next Topic:Equivalent of ROUND in criteria query in JPA 2
Goto Forum:
  


Current Time: Thu Oct 23 22:09:01 GMT 2014

Powered by FUDForum. Page generated in 0.01592 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software