Mongodb 使用查找、展开和项目获取进行聚合;无法使用构造函数“无参数构造函数”实例化java.util.List;虽然

Mongodb 使用查找、展开和项目获取进行聚合;无法使用构造函数“无参数构造函数”实例化java.util.List;虽然,mongodb,kotlin,aggregation-framework,Mongodb,Kotlin,Aggregation Framework,spring-data-mongodb-3.0.5.RELEASE.jar和mongodb-driver-core-4.0.5.jar 我有以下课程 @Document(collection = "customers") data class Customer ( @Id var _id: ObjectId? = null, var custId: String? = null, var custName: String? = null, va

spring-data-mongodb-3.0.5.RELEASE.jar和mongodb-driver-core-4.0.5.jar

我有以下课程

@Document(collection = "customers")
data class Customer (
    @Id var _id: ObjectId? = null,
    var custId: String? = null,
    var custName: String? = null,
    var accounts: List<Account>? = null
) : Serializable
我在看下面的输出

{ "_id" : ObjectId("5d092132237909001a398cc5"), "custId" : {"123"}, { "custName"  : { "Test"}  }, "accounts" : { "accountId" : {"000079537"} : { "accountType" : "Savings" } } }
{ "_id" : ObjectId("5d092132237909001a398cc5"), "custId" : { "123" },  { "custName" : "Test"  }, "accounts" : { "accountId" : {"000079538"},  {"accountType" : "Current" } } }
在Mongoshell中,下面的脚本给出了上面的输出。但是,当我们使用下面的代码来讨论java时,我们看到了“使用构造函数实例化java.util.List失败,没有带参数的构造函数”,我遵循了这一点,但我们仍然看到了相同的问题

db.getCollection("customers").aggregate([{ "$match" : { "$and" : [{ "custId" : "123"}, ]}},
            { "$lookup" : { "from" : "accounts", "localField" : "custId", "foreignField" : "accounts.custId", "as" : "accounts"}}
           , { "$unwind" : "$accounts"}, { "$project" : {  "custId" : 1, "accounts.accountType" : "$accounts.accountType"}} 

        ]
        )
聚合代码

val unwindOperation = Aggregation.unwind("accounts") 
val lookUp = Aggregation.lookup( lookUpCollectionDetails!!.collection, lookUpCollectionDetails.localField, lookUpCollectionDetails.foreignField, lookUpCollectionDetails.attribute ) 
val limit = Aggregation.limit(mongoResultLimit.toLong()) 
val aggregation = Aggregation.newAggregation( Customer::class.java, match, lookUp, unwindOperation, projectionOperation, limit )

请共享聚合查询代码。是java还是kotlin?也分享完整的错误我认为错误是告诉你需要一个具有属性和包含particuler属性的构造函数。而且,代码
{“$match”:{“$And”:[{“custId”:“123”},]}
可以简单地是:``{“$match”:{“custId”:“123”}}`。val unwindoction=Aggregation.unwind(“accounts”)val lookUp=Aggregation.lookUp(lookUpCollectionDetails!!.collection,lookUpCollectionDetails.localField,lookUpCollectionDetails.foreignField,lookUpCollectionDetails.attribute)val limit=Aggregation.limit(mongoResultLimit.toLong())val Aggregation=Aggregation.newAggregation(Customer::class.java,匹配,查找,取消操作,ProjectOnOperation,限制)@sidgate-当我删除取消操作时,我看到下面的错误LinkedList无法映射到StringYou未共享
ProjectOnOperation
val unwindOperation = Aggregation.unwind("accounts") 
val lookUp = Aggregation.lookup( lookUpCollectionDetails!!.collection, lookUpCollectionDetails.localField, lookUpCollectionDetails.foreignField, lookUpCollectionDetails.attribute ) 
val limit = Aggregation.limit(mongoResultLimit.toLong()) 
val aggregation = Aggregation.newAggregation( Customer::class.java, match, lookUp, unwindOperation, projectionOperation, limit )