Tutorial :Table size using JPA query language



Question:

Using JPA query language, how do I determine the size (number of rows) in an entity (table)?


Solution:1

Use the count aggregate function:

EntityManager em = ...  Query q = em.createQuery ("SELECT count(x) FROM Magazine x");  Number result = (Number) q.getSingleResult ();  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »