views:

267

answers:

2

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

+1  A: 

use Query.setMaxResults(..)

Bozho
I am using NamedQuery . Can the functions setFirstResult() and setMaxResults() work with namedQuery??
Richie
Why don't you try reading the javadoc, or open the auto-complete in your IDE and see?
Bozho
+1  A: 

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

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

Mobs
I am using NamedQuery . Can the functions setFirstResult() and setMaxResults() work with namedQuery??
Richie