Consider the following simplified domain model i am currently working on:
case class Product(val id : Long, val name : String, product : Option[Product], category : Option[ProductCategory])
case class Price(val id : Long, val amount : Double, val conditions : Seq[Condition])
trait Condition {
def isTrue(product: Product):Boolean
}
case class ManufacturerNameCondition(val id : Long, val name : String){...}
case class DateCondition(val id : Long, val validFrom : Date, val validTo : Date){...}
What does this model represent?
It represents a simple price service, which allows to define multiple prices for a product or product category. The final price for a product is determined by checking all its matching prices and their associated conditions. E.g. there may be a normal price for a Product and one extra price, which is only active today, because it has a DateCondition.
What is my problem? A Price may be associated with multiple Conditions. Each condition may be of another type. So i am asking myself how this should be solved with Slick (=polymorphic relationships). Basically i want to have a DAO-like interface which fetches the prices along with the associated conditions.
My Questions:
- Is it possible to implement this model with Slick? (probably yes)
- Polymorphic Relationships: Is it a good idea to solve this problem in Slick? Slick states that it wants to overcome the object relational mismatch and here i have the feeling as if i was trying to fight the framework with this model. Does Slick not play well with such an object-oriented approach? Should i choose another approach?
Plz note: Yes, i have no code to show of what i have tried, but right now i need some direction to look for. Currently i am somehow lost :-)