mongodb - SalatDAO deserialization of typed class with list -


i have following case classes:

case class network(val name : string, val mac : string) case class field[t](var value : t, var source : string = "") case class device(var _id : objectid = new objectid,                   var device_type : field[string] = field[string](""),                   var networks : field[list[network]] = new field[list[network]](list[network]())) {   def hasmac(mac : string) : boolean = {     networks.value.foreach { n => if(n.mac == mac) return true }     return false   } } 

i able serialize/deserialze instances of device. however, after deserializtion, hasmac method crashed exception: "classcastexception: com.mongodb.basicdblist cannot cast scala.collection.immutable.list"

when device class defined this

case class device(var _id : objectid = new objectid,                   var device_type : field[string] = field[string](""),                   var networks : list[network] = list[network]()) {   def hasmac(mac : string) : boolean = {     networks.foreach { n => if(n.mac == mac) return true }     return false   } } 

i don't error , works expected.

i saw salat doesn't support option[list], here have field[list]. not understand page if salat supports kind of type : https://github.com/novus/salat/wiki/supportedtypes

aliza

salat developer here.

it looks field[list[network]] not serializing in first place - basicdblist mongo-java-driver's last ditch attempt serialize object treating tuple gets persisted basicdblist.

(and wouldn't save lot of confusion if tell mongo-java-driver blow when encounters doesn't know how serialize instead of converting list , deferring issue until unsuspecting user attempts deserialize document?)

here's test showing parameterized case class contains list parameterized same type.

https://github.com/novus/salat/blob/master/salat-core/src/test/scala/com/novus/salat/test/sortedseqspec.scala#l44-l49

however, can't find spec proving case class parameterized list[foo[x]] work.

please file ticket @ https://github.com/novus/salat/issues

thanks.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -