问题描述: 在使用Spring Data时,使用集合提取指定了firstResult/maxResults时,可能会出现如下警告提示: HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!
问题解决方法:
首先,确保你正在使用的Spring Data版本是最新的。可以通过更新依赖项来解决此问题。
如果你使用的是Hibernate作为持久化提供程序,可以通过设置hibernate.max_fetch_depth属性来解决此问题。将其设置为一个较大的值,例如10或更大。
spring.jpa.properties.hibernate.max_fetch_depth=10
@Query("SELECT e FROM Entity e JOIN FETCH e.collection")
List findAllEntities();
以上是解决“HHH000104:使用集合提取指定了firstResult/maxResults;应用于内存中!”问题的一些常见方法。根据具体情况选择适合你的解决方案。