Conversion from Stream<IMendixObject> to List<IMendixObject> not working

0
Hello,  We are using DBConnecor of Mendix and in databaseconnector::actions::ExecuteQuery.java public java.util.List<IMendixObject> executeAction() throws Exception     {         // BEGIN USER CODE         IMetaObject metaObject = resultObject.getMetaObject();         Stream<IMendixObject> resultStream = connector.executeQuery(             this.jdbcUrl, this.userName, this.password, metaObject, this.sql, this.getContext());                  List<IMendixObject> resultList = resultStream.collect(Collectors.toList());         logNode.trace(String.format("Result list count: %d", resultList.size()));         return resultList;         // END USER CODE   The  resultList returns [] (empty) value.    But executeQuery in jdbcconnector.java   private Stream<Map<String, Optional<Object>>> executeQuery(final String jdbcUrl, final String userName, final String password, final IMetaObject metaObject, final String sql) throws SQLException {     logNode.trace(String.format("executeQuery: %s, %s, %s", jdbcUrl, userName, sql));     try (Connection connection = connectionManager.getConnection(jdbcUrl, userName, password);         PreparedStatement preparedStatement = connection.prepareStatement(sql);         ResultSet resultSet = preparedStatement.executeQuery()) {       ResultSetReader resultSetReader = new ResultSetReader(resultSet, metaObject);             return resultSetReader.readAll().stream();     }   } resultSetReader.readAll() has correct data. So when it converts to Stream and return there seems some issues. Please provide your input on this.     }
asked
1 answers
1

Hello Balaram,

You can try using this if you want to gather your data through a stream for any reason:

return resultSetReader.readAll().stream().collect(Collectors.toList());

You cannot return a stream instead of a list because it’s not a collection.

Hope this helps

answered