Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Hibernate support the limit statement in MySql?

I am working on a project which uses Java,MySql,Struts2 MVC and Hibernate. I tried using limit statement in hql query but its not working properly.

Select t from table1 t where t.column1 = :someVal limit 0,5

EDIT: I am using this as a namedQuery and calling this namedQuery using JPA Template

This works correctly in MySql but when I ran this as a hql query this returns all records without regard to limit statement. Has anyone faced the same problem?? Any help appreciated!!

Regards, RDJ

like image 507
Richie Avatar asked Nov 26 '09 06:11

Richie


People also ask

Does hibernate support MySQL?

Hibernate will then use MySQL's autoincremented database column to generate the primary key values.

What is Java Hibernate using MySQL?

Hibernate is an ORM (Object-Relational Mapping) tool that is used to save the Java objects in the database system. As an object-oriented query language, JPA uses JPQL (Java Persistence Query Language) to execute database operations.


1 Answers

Use hibernates functions for paging! setFirstResult(), setMaxResults()

http://www.javalobby.org/java/forums/t63849.html

like image 97
Mobs Avatar answered Oct 02 '22 18:10

Mobs