Error: BasicDBList cannot be cast to List

93 views
Skip to first unread message

stephanos

unread,
Jun 12, 2012, 7:19:56 AM6/12/12
to rogue...@googlegroups.com
I'm having a little trouble with subselects and can't figure out why. I have a collection of apps, each document has a field 'team' where 'team members' are listed. 

To find a team member via his user id I wrote this:

def findTeamMember(appId: Int, userId: ObjectId): Option[TM] =
    for {
        result <- AppCol.where(_._id eqs appId)
            .scan(_.team.subfield(_.members.subfield(_.user.subfield(_.id))) in List(userId))
            .select(_.team.subselect(_.members)).get()
        members <- result.headOption
        member <- members.headOption
    } yield member

But I keep getting this error:

Caused by: java.lang.ClassCastException: com.mongodb.BasicDBList cannot be cast to scala.collection.immutable.List
at com.mycompany.TeamReader$$anonfun$findTeamMember$9$$anonfun$apply$14.apply(TeamReaderComp.scala:62) 
at scala.Option.flatMap(Option.scala:146) 
at com.mycompany.TeamReader$$anonfun$findTeamMember$9.apply(TeamReaderComp.scala:62)
at com.mycompany.TeamReader$$anonfun$findTeamMember$9.apply(TeamReaderComp.scala:58) 
at scala.Option.flatMap(Option.scala:146)
at com.mycompany.TeamReader.findTeamMember(TeamReaderComp.scala:58) 

What could I do about it?

stephanos

unread,
Jun 12, 2012, 9:50:47 AM6/12/12
to rogue...@googlegroups.com
Hm, when I use

  AppCol
    .where(_._id eqs sourceId)
    .scan(_.team.subfield(_.members.subfield(_.user.subfield(_.id))) in List(userId))
    .select(_.team.subfield(_.members))
    .get().headOption.getOrElse(Empty).getOrElse(List()).headOption

it says

  java.lang.ClassCastException: com.mongodb.BasicDBList cannot be cast to scala.collection.TraversableLike

Jason Liszka

unread,
Jun 13, 2012, 12:09:07 PM6/13/12
to rogue...@googlegroups.com
Hm, not sure without looking at how your models are declared, in particular the types of all the fields involved. Could you send that over?

stephanos

unread,
Jun 14, 2012, 7:46:41 AM6/14/12
to rogue...@googlegroups.com
I will send you the relevant code in a private mail.


On Wednesday, June 13, 2012 6:09:07 PM UTC+2, Jason Liszka wrote:
Hm, not sure without looking at how your models are declared, in particular the types of all the fields involved. Could you send that over?
Reply all
Reply to author
Forward
0 new messages