这里是下面只有2场表:
customer_order_base { cust_id, cust_lookup_fact }
这已被映射到所谓的CustomerOrderBase
使用这两个领域的实体。我需要创建其他几个表其中一些只使用性能方面的原因这些表中的字段的子集有40多个领域的较轻的实体模型。
这些新创建的轻质实体也指向同一个数据库表中的重量级机型。
不幸的是,我现在也遇到了其中有只有2个领域上表customer_order_base
。是否有可能创造另一个实体映射到这个表?我只是想用它来阅读目的,与其他表连接。
如果没有这个表,我不能做必要的连接所需要用一些表。
Is the first case done like this? Using the 2 columns which already exist in the original mapping?
@Immutable
@Entity("DuplicateCustomerOrderBasename=")
@Table("customer_order_base")
public class DuplicateCustomerOrderBase {
@Id
@Generator(...)
BigInteger cust_id;
@Column(name="cust_fact", insertable="false", updatable="false")
private String cust_lookup_fact;
}
我知道只有两种方式来映射同桌不同的实体:
第一:
整个表映射到实体。你可以更多的实体映射到同一个表,但是你有org.hibernate.annotations.Immutable
注释这些(小)的实体。您不能修改这些小实体。
第二:
使用带有继承策略InheritanceType.SINGLE_TABLE
继承。
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Base {
@Id
private Long id;
}
@Entity
@DiscriminatorValue("SubBase")
public class SubBase1 extends Base {
private String value1;
}