Java N+;1选择generete通信异常

Java N+;1选择generete通信异常,java,spring,hibernate,spring-boot,spring-data,Java,Spring,Hibernate,Spring Boot,Spring Data,我有一个简单的控制器 @GetMapping("users") List<User> getUsers() { 但对于95%的电话来说,它是有效的 如果我减少迭代次数: for(int i = 0; i<100;++i) userRepository.getOne(i); 代码只是为了说明这个问题,一个真实的例子来自N+1选择 如何防止org.hibernate.exception.JDBCConnectionException:无法提取结果集?您可以发布完整的

我有一个简单的控制器

@GetMapping("users")
List<User> getUsers() {
但对于95%的电话来说,它是有效的

如果我减少迭代次数:

for(int i = 0; i<100;++i)
      userRepository.getOne(i);
代码只是为了说明这个问题,一个真实的例子来自N+1选择


如何防止org.hibernate.exception.JDBCConnectionException:无法提取结果集?

您可以发布完整的堆栈跟踪吗?这听起来像是您的数据库在连接打开太长时间时关闭连接,或者导致太多负载,或者执行太多语句。完整的堆栈跟踪可能会证明这一点。您可能想和dba谈谈。您可以发布完整的stacktrace吗?这听起来像是您的数据库在打开太长时间时关闭了连接,或者导致了太多负载,或者执行了太多语句。完整的堆栈跟踪可能会证明这一点。您可能想和dba谈谈。
org.hibernate.exception.JDBCConnectionException: could not extract ResultSet
for(int i = 0; i<100;++i)
      userRepository.getOne(i);
spring.datasource.url=jdbc:mysql://test.dailyrazor.com:3306/test?autoReconnect=true&failOverReadOnly=false&maxReconnects=10
spring.datasource.username=test
spring.datasource.password=test