Salat MongoDB argument type mismatch

1.2k views Asked by At

I have a case class that I map to the Salat library using the SalatDAO extentions. In this case class, one of the parameters is an Enum type. When I run it to fetch the data from the database, I get the following error:

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
------------------------------------------------------------

Here is the Enum object that has the Salat annotations. Am I missing something?

@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

There are 1 answers

1
tmbo On BEST ANSWER

The error message of

---------- 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

suggests that you are expecting an enumeration value but the database contains an Option[Enumeration.Value].