Skip to main content



      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 01:41 Go to next message
Eclipse UserFriend
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 02:48 Go to previous messageGo to next message
Eclipse UserFriend
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 11:48 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Merge resets new data
Next Topic:Equivalent of ROUND in criteria query in JPA 2
Goto Forum:
  


Current Time: Sun Jul 27 10:12:54 EDT 2025

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

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

Back to the top