对“每个具体类映射一张表”(table per concrete-class)的映射策略而言,隐式多态的 方式有一定的限制。而<union-subclass>映射的限制则没有那 么严格。

下面表格中列出了在Hibernte中“每个具体类一张表”的策略和隐式多态的限制。

表 9.1. 继承映射特性(Features of inheritance mappings)

继承策略(Inheritance strategy)多态多对一多态一对一多态一对多多态多对多多态 load()/get()多态查询多态连接(join)外连接(Outer join)读取
每个类分层结构一张表<many-to-one><one-to-one><one-to-many><many-to-many>s.get(Payment.class, id)from Payment pfrom Order o join o.payment p支持
每个子类一张表<many-to-one><one-to-one><one-to-many><many-to-many>s.get(Payment.class, id)from Payment pfrom Order o join o.payment p支持
每个具体类一张表(union-subclass)<many-to-one><one-to-one><one-to-many> (仅对于inverse="true"的情况)<many-to-many>s.get(Payment.class, id)from Payment pfrom Order o join o.payment p支持
每个具体类一张表(隐式多态)<any>不支持不支持<many-to-any>s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()from Payment p不支持不支持