Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

entityManager produces incorrect SQL when using limit

 
Erik Deveza
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using javax.persistence.EntityManager to query my table. My query.getResultList() works perfectly when using setFirstResult method, but when I use setMaxResults method, it produces the following error:



When I checked the actual query the limit keyword is placed right after the SELECT keyword, it should be after the statement. Why is the entityManager producing incorrect statement? I am currently using MySQLDialect. I also tried MySQLMyISAMDialect and MySQLInnoDBDialect, but it didn't work as well.

Any input is highly regarded.
 
Erik Deveza
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After double checking my config file, hibernate.dialect was set to "org.hibernate.dialect.HSQLDialect".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic