I have a case class composition that looks like below:
case class TypeA(id: Int, text: String, typeBList: List[TypeB])
case class TypeB(id: Int, text: String)
I use MongoDB for persisting the data and the resulting JSON document looks like:
TypeA {
id: 101,
text: "This is of type A",
typeBList: [
{id: 1001, text: "First TypeB text"},
{id: 1002, text: "Second TypeB text"}
]
}
How can I represent my SalatDAO that would help me use it's API and box the results of the find operation to the respective types? Is it automagically done or should I use some annotations?
Salat author here. If TypeB is actually a type hierarchy, you need to annotate it with
@Salat
- otherwise, you don't need to do anything special.If you need help, feel free to make a small sample project on Github and I will be happy to fork and fix it so you can have a working example.