Using JPA query language, how do I determine the size (number of rows) in an entity (table)?
Use the count aggregate function:
EntityManager em = ...
Query q = em.createQuery ("SELECT count(x) FROM Magazine x");
Number result = (Number) q.getSingleResult ();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With