UPDATE:私の現在の状況を反映するために、サンプルを変更リフトマッパー - OneToManyマッピングとトレイト
かなり持ち上げて新しいと私は自分のアプリケーションのためのモデルを作成しようとしています。私はDRYの精神に物事を残したいので、私は、私のモデルのフィールドのいくつかを指定するために、特性ミックスインを使いたいと思っています。私は従業員の内の1つのマッピングに多くのcontactInfosを持って見ることができるように
trait Person[T <: LongKeyedMapper[T]] extends LongKeyedMapper[T]{
self: T =>
object firstName extends MappedString[T](this, 50)
object lastName extends MappedString[T](this, 50)
object civicRegNumber extends MappedString[T](this, 12)
}
class Employee extends IdPK with OneToMany[Long, Employee] with Person[Employee] {
def getSingleton = Employee
object contactInfos extends MappedOneToMany(EmployeeContactInfo, EmployeeContactInfo.person)
}
object Employee extends Employee with LongKeyedMetaMapper[Employee]
:例えば、私は私が私のEmployee
クラスにミックスインPerson
形質を持っています。これが動作しているようですが、私は私のPerson
特性にcontactInfosオブジェクトを移動したい
trait PersonContactInfo[T <: LongKeyedMapper[T],P <: Person[P]] extends LongKeyedMapper[T] {
self: T =>
object email extends MappedEmail[T](this, 80)
def personMeta:P with LongKeyedMetaMapper[P]
object person extends LongMappedMapper[T,P](this, personMeta)
}
class EmployeeContactInfo extends IdPK with PersonContactInfo[EmployeeContactInfo, Employee] {
def getSingleton = EmployeeContactInfo
val personMeta = Employee
}
object EmployeeContactInfo extends EmployeeContactInfo with LongKeyedMetaMapper[EmployeeContactInfo]
:ように見えます。しかし、私はこれを達成する方法を理解することはできません... OneToManyの特性を継承することは可能ですか?助けを歓迎します!