Understanding Collection Support

28 views
Skip to first unread message

Daniel Eggert

unread,
Apr 16, 2012, 7:22:47 AM4/16/12
to scala...@googlegroups.com
I'm (still) new to Salat and Scala and I'm having trouble understanding the collection support. I have

case class Move(@Key("_id") id: ObjectId = new ObjectId, fromAddress: String, toAddress: String, owner: ObjectId, log: Option[scala.collection.immutable.Seq[LogEntry]])

object MoveDAO extends SalatDAO[Move, ObjectId](collection = Database.collection("moves"))

but when I try to use

val move1 = Move(fromAddress = u fromAddress, toAddress = u toAddress, owner = userID.get, log = None)

I get this error:

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[NoSuchMethodError: api.model.Move.<init>(Lorg/bson/types/ObjectId;Ljava/lang/String;Ljava/lang/String;Lorg/bson/types/ObjectId;Lscala/Option;)V]]

What am I missing here?

Daniel

rktoomey

unread,
Apr 16, 2012, 9:51:51 AM4/16/12
to scala-salat
Sorry, Salat does not support a collection wrapped in an Option.

On Apr 16, 7:22 am, Daniel Eggert <daniel.egg...@umzugsagenten.de>
wrote:
> I'm (still) new to Salat and Scala and I'm having trouble understanding the
> collection support. I have
>
> case class Move(@Key("_id") id: ObjectId = new ObjectId, fromAddress:
> String, toAddress: String, owner: ObjectId, log:
> Option[scala.collection.immutable.Seq[LogEntry]])
>
> object MoveDAO extends SalatDAO[Move, ObjectId](collection =
> Database.collection("moves"))
>
> but when I try to use
>
> val move1 = Move(fromAddress = u fromAddress, toAddress = u toAddress,
> owner = userID.get, log = None)
>
> I get this error:
>
> play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception
> [[NoSuchMethodError:
> api.model.Move.<init>(Lorg/bson/types/ObjectId;Ljava/lang/String;Ljava/lang /String;Lorg/bson/types/ObjectId;Lscala/Option;)V]]

Daniel Eggert

unread,
Apr 16, 2012, 11:06:18 AM4/16/12
to scala...@googlegroups.com
That's ok. But even without the option, I'm not having any luck getting in to work:


case class Move(@Key("_id") id: ObjectId = new ObjectId, fromAddress: String, toAddress: String, owner: ObjectId, log: Seq[LogEntry] = new scala.collection.mutable.ListBuffer[LogEntry])

with

@Salat
abstract class LogEntry(date: DateTime = new DateTime) {
def entryType: LogEntryType.Value
}

case class FreeTextLogEntry(text: String, override val entryType: LogEntryType.Value = LogEntryType.FreeText) extends LogEntry

Now when I run

val move1 = Move(fromAddress = u fromAddress, toAddress = u toAddress, owner = userID.get)

I get

java.lang.NoSuchMethodError: api.model.Move.<init>(Lorg/bson/types/ObjectId;Ljava/lang/String;Ljava/lang/String;Lorg/bson/types/ObjectId;Lscala/collection/Seq;)V


I'm quite new to all of this… :(

Daniel
Reply all
Reply to author
Forward
0 new messages