我试图通过使用Spring Boot mongo客户端从Mongo数据库中获取数据。 但是我从我的应用程序中摆脱了内存异常
如何解决/优化此问题?
Bson productFilter = Filters.eq(RubricConfig.PRODUCT, tenantId);
// let's get system rubrics first
final List<Document> systemRubrics = mongoClient.getDatabase(mongoProperties.getDatabase())
.getCollection(config.getRubricsCollectionName())
.find(new Document(RubricConfig.SYSTEM_RUBRIC_PROPERTY_NAME, Boolean.TRUE)).filter(productFilter)
.into(new ArrayList<Document>());
// get user rubrics created by this user
final List<Document> userRubrics = mongoClient.getDatabase(mongoProperties.getDatabase())
.getCollection(config.getRubricsCollectionName())
.find(new Document(RubricConfig.CREATED_BY_PROPERTY_NAME, userId)).filter(productFilter)
.into(new ArrayList<Document>());