Morphia中的错误映射字段

时间:2014-05-30 03:56:39

标签: scala morphia

当我尝试在Morphia中使用save方法保存Campaign实例时。我有错误映射字段异常。我该如何解决?

Error mapping field:Campaign.adgroups

@Entity(value = "campaign", noClassnameStored = true)
class Campaign {
  @Id
  var id = new ObjectId
  var name = ""
  var uid = new ObjectId
  var adgroups = new ListBuffer[AdGroup]
  var created_at = ""
  var comment = ""
}

@Entity(value = "ad", noClassnameStored = true)
class Ad{
  @Id
  var id = new ObjectId
  var name = ""
  var uid = new ObjectId
  var ads = new ListBuffer[Ad]
  var created_at = ""
  var comment = ""
}

1 个答案:

答案 0 :(得分:0)

Morphia不知道Scala的ListBuffer是什么。您需要为该类型提供转换器。一旦完成,你就像这样告诉morphia:

morphia.getMapper().getConverters().addConverter(ListBufferConverter.class);