有没有办法使用Mapper o Record Framework在Lift中定义适当的继承模型,其中有一个父类表和一个每个子表一个表? 假设你想使用继承来在每个子类中使用相同的映射字段,我通过对这些字段使
trait SuperFields[T <: Mapper[T]] { self: T => object DESCRIPTION extends MappedString[T](this, 255) object BRAND extends MappedString[T](this, 50) // etc }
然后每个Mapper / MetaMapper将扩展SuperFields,但是定义他们自己的数据库表和连接标识符:
class Product extends Mapper[Product] with SuperFields[Product] { override def getSingleton = Product } object Product extends Product with MetaMapper[Product] { override def dbTableName = "PRODUCT" override def dbDefaultConnectionIdentifier = SomeConnection }
和:
class Service extends Mapper[Service] with SuperFields[Service] { override def getSingleton = Service } object Service extends Service with MetaMapper[Service] { override def dbTableName = "SERVICE" override def dbDefaultConnectionIdentifier = SomeOtherConnection }