Salat MongoDB参数类型不匹配

时间:2013-12-19 20:39:31

标签: mongodb scala salat

我有一个案例类,我使用SalatDAO扩展映射到Salat库。在这种情况下,其中一个参数是Enum类型。当我运行它来从数据库中获取数据时,我收到以下错误:

com.novus.salat.util.ToObjectGlitch: 

  argument type mismatch

  $anon$2(class domain.content.Question @ com.novus.salat.global.package$$anon$1@294ce5eb) toObject failed on:
  SYM: domain.content.Question
  CONSTRUCTOR
public domain.content.Question(int,java.lang.String,scala.collection.immutable.List<domain.content.Answer>,scala.Enumeration$Value,boolean)

---------- CONSTRUCTOR EXPECTS FOR PARAM [0] --------------
NAME:         id
TYPE:         int
DEFAULT ARG   [Missing, but unnecessary because input value was supplied]
@Ignore       false
---------- CONSTRUCTOR INPUT ------------------------
TYPE: java.lang.Integer
VALUE:
1001
------------------------------------------------------------


---------- CONSTRUCTOR EXPECTS FOR PARAM [1] --------------
NAME:         text
TYPE:         java.lang.String
DEFAULT ARG   [Missing, but unnecessary because input value was supplied]
@Ignore       false
---------- CONSTRUCTOR INPUT ------------------------
TYPE: java.lang.String
VALUE:
Which is a valid java access modifier?
------------------------------------------------------------


---------- CONSTRUCTOR EXPECTS FOR PARAM [2] --------------
NAME:         answers
TYPE:         scala.collection.immutable.List<domain.content.Answer>
DEFAULT ARG   [Missing, but unnecessary because input value was supplied]
@Ignore       false
---------- CONSTRUCTOR INPUT ------------------------
TYPE: scala.collection.immutable.$colon$colon[B]
VALUE:
List(Answer(1,private,true,None), Answer(2,personal,false,None), Answer(3,protect,false,None), Answe...
------------------------------------------------------------


---------- CONSTRUCTOR EXPECTS FOR PARAM [3] --------------
NAME:         quesType
TYPE:         scala.Enumeration$Value
DEFAULT ARG   [Missing, but unnecessary because input value was supplied]
@Ignore       false
---------- CONSTRUCTOR INPUT ------------------------
TYPE: scala.None$[scala.runtime.Nothing$]
VALUE:
None
------------------------------------------------------------


---------- CONSTRUCTOR EXPECTS FOR PARAM [4] --------------
NAME:         isSourceCodeAvailable
TYPE:         boolean
DEFAULT ARG   [Missing, but unnecessary because input value was supplied]
@Ignore       false
---------- CONSTRUCTOR INPUT ------------------------
TYPE: java.lang.Boolean
VALUE:
false
------------------------------------------------------------

这是具有Salat注释的Enum对象。我错过了什么吗?

@EnumAs(strategy = EnumStrategy.BY_ID)
object QuestionTypeEnum extends Enumeration {

  val MULTI_CHOICE = Value("MULTI_CHOICE")
  val RADIO_BUTTON = Value("RADIO_BUTTON")
  val DRAG_AND_DROP = Value("DRAG_AND_DROP")

}

1 个答案:

答案 0 :(得分:0)

的错误讯息
---------- CONSTRUCTOR EXPECTS FOR PARAM [3] --------------
NAME:         quesType
TYPE:         scala.Enumeration$Value
DEFAULT ARG   [Missing, but unnecessary because input value was supplied]
@Ignore       false
---------- CONSTRUCTOR INPUT ------------------------
TYPE: scala.None$[scala.runtime.Nothing$]
VALUE:
None

建议您期望枚举值,但数据库包含Option[Enumeration.Value]