[英]is it possible to maintain the different schema in same entity class
I have two schema(claim and policy). 我有两个架构(声明和政策)。 For both schema am using same Entity class. 对于两个架构,我使用相同的Entity类。 My problem is, claim schema has column city but policy schema does have city column. 我的问题是,声明架构有列城市但政策架构确实有城市列。 So If I use entity class by policy schema I get error. 所以如果我按策略模式使用实体类,我会收到错误。 is this only the way to change the Entity class for each schema ? 这只是改变每个模式的Entity类的方法吗? or is it possible to maintain the different schema in same entity class? 或者是否可以在同一个实体类中维护不同的模式?
My Entity class : 我的实体类:
@Entity
@Table(name = "Table_name")
public class X {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "xxx")
private int xxx;
@Column(name = "yyy")
private String yyy;
@Column(name = "city")
private String city; // only claim schema
}
I get the schema like this, 我得到这样的架构,
if(id.startsWith("SW")){
session = getSWSession();
}
if(id.startsWith("HW")){
session = getHWSession();
}
您需要为不同的模式使用两个不同的映射,因此您必须创建两个Java映射类,并使用Table批注对它们进行批注,以标记每个特定实体的模式 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.