Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,在 mysql 中,有一种方法可以在使用 LIMIT 选择后获得总计数,只需选择 FOUND_ROWS。有没有办法在 jpa 中做到这一点?
我使用 JPA 和 Hibernate 作为持久性提供程序和 MySQL 作为底层数据库。
如果解决方案不是“纯”jpa 甚至休眠,那就没问题了。
不,JPA 中没有这样的构造,Hibernate 中也没有开箱即用。
直接的解决方案当然是通过单独的查询来获得总数。如果这不是一个选项,那么一种可能性是创建拦截器,如此处所述。