public void grpcGpioDevice(StreamObserver<NI_GetAllDeviceListResponse> responseObserver, Map<String, VsGrpc> vcuMap) { Session session = null; final StringBuffer sb = new StringBuffer("select name,vs_id," + "description,direction,device_id,vx_external_id from EMS_GPIO_DEVICE "); try { session = getSession(); Query query = session.createSQLQuery(sb.toString()).setFetchSize(grpcRspNumber); ScrollableResults results = query.scroll(); List<GpioDevice> gpioList = new ArrayList<>(); while(results.next()) { Object[] obj = results.get(); GpioDevice gd = new GpioDevice(); gd.setName(obj[0] == null ?"":obj[0].toString()); gd.setVsId(obj[1] == null ?"":obj[1].toString()); gd.setDescription(obj[2] == null ?"":obj[2].toString()); gd.setDirection(obj[3] == null ?0:Integer.parseInt(obj[3].toString())); gd.setDeviceId(obj[4] == null ?"":obj[4].toString()); gd.setVxExternalId(obj[5] == null ?"":obj[5].toString()); gpioList.add(gd); if(gpioList.size()==grpcRspNumber) { NI_GetAllDeviceListResponse.Builder response = NI_GetAllDeviceListResponse.newBuilder(); grpcFlowResult.getAiAoDiDoInfo(null, gpioList, vcuMap, "DIDO", response); grpcFlowResult.result(response, responseObserver); gpioList.clear(); } } if(gpioList.size()>0 && gpioList.size()<grpcRspNumber) { NI_GetAllDeviceListResponse.Builder response = NI_GetAllDeviceListResponse.newBuilder(); grpcFlowResult.getAiAoDiDoInfo(null, gpioList, vcuMap, "DIDO", response); grpcFlowResult.result(response, responseObserver); gpioList.clear(); } }catch (RuntimeException e) { e.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } finally { releaseSession(session); } }