问题描述
我收到此错误com.mysql.jdbc.PacketTooBigException,并在代码中进行了跟踪,看来它出现在以下情况下(但仅在测试中发生)
public interface Students extends JpaRepository<Student,Integer> {
@EntityGraph("Student.withProgramAndSchedule")
@Query("from Student s")
Iterable<Student> findAllWithProgramAndSchedule();
}
@Entity
@NamedEntityGraph(
name = "Student.withProgramAndSchedule",attributeNodes = {
@NamedAttributeNode("programEnrollments"),@NamedAttributeNode("schedules")
}
)
public class Student implements Serializable {
...
}
仅在DataJpaTest期间,即使我已经清除了实体管理器,它似乎也无法清理实体管理器上下文
@After
public void clearEntityManager() {
entityManager.clear();
}
由于这是匿名的真实数据,因此它具有成千上万的记录,发生的事情是创建了一个看起来像
的查询select ... from ... where studentSchedule_0.id in (?,?,... thousands of ? later,... ?)
然后,它超出了1MB的数据包限制。
所以我的问题是(因为我无法在参考文献中找到它)在进行ID提取时是否可以限制查询的大小?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)