Re: [salat] Salat and generic type parameters

44 views
Skip to first unread message

rose katherine toomey

unread,
Apr 22, 2013, 9:13:16 AM4/22/13
to scala-salat
Hi Jonas,

Indeed templating only works for collections.  

So Salat doesn't support this now: the reason you are seeing ["hello world"] as a single-entry array is because Salat is not correctly serializing the C instance, which leads to the mongo-java-driver shrugging and as a last-ditch effect turning the instance of C into a DBList of its field values.

Entered as:

Best,
Rose


On 18 April 2013 09:45, <jo...@ifany.org> wrote:
Hi All,

I have a test case that I can't get to work. I suspect it's because Salat doesn't support it, but I just wanted to check here.

If we have the following classes and traits:

@Salat
trait A

case class C(x : String) extends A

case class P[T <: A](c : T)

And I run

val p = P(C("hello world"))
val dbo = grater[P[C]].asDBObject(p)

I get:

dbo: com.mongodb.casbah.Imports.DBObject = { "c" : [ "hello world"]}

and not

dbo: com.mongodb.casbah.Imports.DBObject = { "c" : { "x" : "hello world" } } 

Is there anything I can do to make this work, or how would I work around it the easiest way?

I browsed the mailing list before asking and found that the question has been asked before here: https://groups.google.com/forum/?fromgroups=#!searchin/scala-salat/generics/scala-salat/UaFCtFtJ1sY/up4OV4mEbPoJ, but it wasn't answered so I've taken the liberty to raise it again.

Thanks for a great tool, by the way.

Jonas

--
You received this message because you are subscribed to the Google Groups "scala-salat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-salat...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages