novus/salat — Issue #27: SalatDAO should support polymorphic collections
Author: mariussoutier
Created: 2012-01-21 22:38:37+00:00
State: open

Hi,

I'm quite new to MongoDB and Salat, but as far as I understand, I cannot use polymorphic collections (I mean collections typed with an abstract supertype) with the SalatDAO class. So the following currently code throws a compiler error:

```scala
case class User(_id: ObjectId = new ObjectId, email: String, password: String, roles: Seq[Role] = Nil)

@Salat
sealed abstract class Role(user: ObjectId)
case class AdminRole(user: ObjectId) extends Role(user)
case class EditorRole(user: ObjectId) extends Role(user)

class UserDAO extends SalatDAO[User, ObjectId](collection = DB.connection("users") {
// Doesn't work because of type constraints
val roles = new ChildCollection[Role, ObjectId](collection = DB.connection("roles"), parentIdField = "user") {}
}
```

Is there a way around this or do you plan to support polymorphic hierarchies in SalatDAO?

Thanks,
- Marius