Even it is very old ticket and discussion but it is very useful. Suppose you have JPA code that connect to mysql then you can not use mysql specific SQL to fetch data.
Example:
SELECT * FROM TableName s ORDER BY id ASC LIMIT 5 OFFSET 10
you can not use this sql while fetch data using JPA.
Use below code to do the same limit sql in JPA
String sql = "SELECT * FROM TableName";
Query query = em.createQuery(sql);
query.setFirstResult(firstPosition);
query.setMaxResults(numberOfRecords);
List result = query.getResultList();
Thanks,
Binod Suman
http://binodsuman.blogspot.com
[Message sent by forum member 'binodsuman']
http://forums.java.net/jive/thread.jspa?messageID=471507