Hi all,
This is my first post in this forum and i hope this is the right place to do it.
I've been searching all over the web, but i couldn't find anything significantly similar to my problem.
This is the peace of code that i'm using to submit the query:
Code:
public List<BlogEntryExtended> findExtendedBlogEntries( int max )
throws SystemException
{
try
{
Session session = getHibernateTemplate().getSessionFactory().openSession();
Query query = session.getNamedQuery( "selectFeaturedEntries" );
query.setMaxResults( max );
List<BlogEntryExtended> list = (List<BlogEntryExtended>)query.list();
}
catch
{
// log exception.
}
finally
{
session.close();
}
}
Here is the query:
Code:
FROM BlogEntryExtended bee
WHERE bee.blogsEntry.draft = false
AND bee.featured = true
ORDER BY bee.blogsEntry.displayDate DESC
And here is the main error:
Code:
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL serve
r version for the right syntax to use near '3 blogentrye0_.entryId as entryId1_, blogentrye0_.thumbnail as thumbnail1_, blog' at line 1
The problem seems to be on the number "3" at the beginning of the query. This is the value for the method parameter variable "max" in this execution.
According to what i have read, the query should be generated with a "LIMIT" keyword to "cut" the resultset.
Just to let you know, i'm using MySQL 5.1, tomcat 6.0.18, and hibernate 3.2.6
Thanks for your help.