我有一个具有子类作为属性的对象:
case class UpgradeInfo(
@EnumAs upgradeType: UpgradeType.Value,
@EnumAs timeUnit: TimeUnit.Value,
timeQuantity: Int,
start: Date,
end: Date)
case class Upgrade(
@Key("_id") id: ObjectId = new ObjectId,
adId: ObjectId,
upgradeInfo: UpgradeInfo,
price: Double)
创建和更新对象工作正常,但是当我尝试使用此代码检索升级对象时(应该检索所有升级对象):
UpgradeDAO.find(MongoDBObject()).toList
我得到以下异常:
[error] Exception: class models.entities.Upgrade requires value for 'upgradeInfo' (Grater.scala:402)
[error] com.novus.salat.DefaultArg.safeValue$lzycompute(Grater.scala:406)
[error] com.novus.salat.DefaultArg.safeValue(Grater.scala:402)
[error] com.novus.salat.ConcreteGrater.safeDefault(Grater.scala:363)
[error] com.novus.salat.ConcreteGrater$$anonfun$5$$anonfun$apply$3.apply(Grater.scala:262)
[error] com.novus.salat.ConcreteGrater$$anonfun$5$$anonfun$apply$3.apply(Grater.scala:262)
[error] com.novus.salat.ConcreteGrater$$anonfun$5.apply(Grater.scala:262)
[error] com.novus.salat.ConcreteGrater$$anonfun$5.apply(Grater.scala:247)
[error] com.novus.salat.ConcreteGrater.asObject(Grater.scala:247)
[error] com.novus.salat.dao.SalatMongoCursorBase$class.next(SalatMongoCursor.scala:45)
[error] com.novus.salat.dao.SalatMongoCursor.next(SalatMongoCursor.scala:151)
[error] com.novus.salat.dao.SalatMongoCursor.foreach(SalatMongoCursor.scala:151)
[error] com.novus.salat.dao.SalatMongoCursor.to(SalatMongoCursor.scala:151)
[error] com.novus.salat.dao.SalatMongoCursor.toList(SalatMongoCursor.scala:151)
[error] models.entities.UpgradeDAO$.find(Upgrade.scala:47)
[error] models.UpgradeSpecs$$anonfun$1$$anonfun$apply$28$$anonfun$apply$29.apply(UpgradeSpecs.scala:129)
[error] models.UpgradeSpecs$$anonfun$1$$anonfun$apply$28$$anonfun$apply$29.apply(UpgradeSpecs.scala:128)
[error] play.api.test.Helpers$.running(Helpers.scala:40)
[error] models.UpgradeSpecs$$anonfun$1$$anonfun$apply$28.apply(UpgradeSpecs.scala:128)
[error] models.UpgradeSpecs$$anonfun$1$$anonfun$apply$28.apply(UpgradeSpecs.scala:128)
知道我做错了什么吗?