aspose file tools*
The moose likes Scala and the fly likes Scala Casbah - Cast Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Scala
Bookmark "Scala Casbah - Cast Exception" Watch "Scala Casbah - Cast Exception" New topic
Author

Scala Casbah - Cast Exception

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

I'm using the Casbah library to fetch results from a MongoDB database. I'm noticing a strange error when I wanted to transform from the DBObject types to my case classes.

This is my collection in the database:



I want the array of answers to box to my Answer case class which is represented as a List in my Question case class as List[Answer]. The method below would do that for me:



The result of the method above when called like:



is the following RuntimeException:



Why is this? I'm explicitly passing Answer to the toList method call. Why should it fail?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

I got rid of this error by using Salat DAO framework for Scala and MongoDBI got rid of this error by using Salat DAO library for Scala and MongoDB. Salat library has very good wrappers around Casbah that eliminates the need to converting between object types. It is all done behind the scenes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scala Casbah - Cast Exception