我在我的应用程序中使用hibernate创建了Device
表。每个Device
对象包含3种类型的对象,如SADevicede
,TXDeviceType
,RxDeviceType
。 (即)设备具有SADeviceType,TXDeviceType,RxDeviceType的列表我的目标是为每个SADevicetype,TXDeviceType和RxDeviceType生成具有用户定义的限制的警报。这意味着设备A的 SADeviceType只应生成重大错误。 设备A的 TXDeviceType应该只为轻微错误生成。 设备B的 SADeviceType,TXDeviceType应该为Major和Minor错误产生警报。我们可以在Hibernate中的每个类层次结构中使用鉴别器作为多对一关系
我想用表中每个类的层次结构这个。例如,我想创建AlarmRestrictionDetail类,并且该子类是SAAlarmDetail,TXAlarmDetail和RxAlarmDetail。如果我打算通过使用hibernate创建它,那么如果鉴别器作为多对一关系在每个类层次结构 中运输并且如何在一个鉴别器列中生成三个外键,它将如何处理?
如果这不是个好主意,那么当我使用hibernate时,是否有人能够帮助我确定哪种表结构是最好的?
参考代码如下
public class Device {
private Integer id;
private List<SADevicetype> saDeviceTypeList;
private List<RxDeviceType> rxDeviceTypeList;
private List<TXDeviceType> txDeviceTypeList;
}
public class AlarmRestrictionDetail {
public Integer id;
public String alarmName;
public String severity;
}
public class SAAlarmDetail extends AlarmRestrictionDetail{
// device type is a discriminator column
public SADevicetype deviceType;
}
public class TXAlarmDetail extends AlarmRestrictionDetail {
// device type is a discriminator column
public TXDeviceType deviceType;
}