Playframework 如何让继承在我的模型层中工作?

Playframework 如何让继承在我的模型层中工作?,playframework,Playframework,我知道您应该扩展模型,以获得所有jpa功能。但是,java不允许多重继承。。。因此,我想知道如何设计以下设计: public class Person extends Model { } // should be able to extend Person public class Doctor extends Model { } // should be able to extend Person public class Patient extends Model { } p

我知道您应该扩展
模型
,以获得所有jpa功能。但是,java不允许多重继承。。。因此,我想知道如何设计以下设计:

public class Person extends Model {
}

// should be able to extend Person
public class Doctor extends Model {
}

// should be able to extend Person     
public class Patient extends Model {
}

public class Item extends Model {
    // Doens't matter whether it's a Doctor or a Patient
    @ManyToMany
    public List<Person> owners;
}
公共类人员扩展模型{
}
//应该能够扩展人
公立医生扩展模型{
}
//应该能够扩展人
公共类病人扩展模型{
}
公共类项扩展模型{
//不管是医生还是病人
@许多
公开名单所有者;
}

提前感谢。

您的医生和患者对象应继承自Person。Java不允许多重继承,但您可以使用已经继承模型的Person扩展子对象


public class Person extends Model {
}

public class Doctor extends Person {
}

public class Patient extends Person{
}

public class Item extends Model {
    @ManyToMany
    public List owners;
}
在Java中无法执行的操作是:



public class Doctor extends Person, Model {
}


谢谢,我知道Java处理继承的方式。我不确定Play会如何处理这个问题。在一个超类中扩展模型,然后再扩展那个超类,效果非常好。我是一个JPA用户,我正在学习如何让游戏为我封装这一切。有时候我想看看发生了什么。但我必须承认,这出戏做得很好,我真的很喜欢它=)