Reputation: 636
I have two schema(claim and policy). For both schema am using same Entity class. 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 ? 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();
}
Upvotes: 4
Views: 1712
Reputation: 153950
You need to have two different mappings for different schema, so you have to create two java mapping classes and annotate them with the Table annotation to mark the schema for each specific entity.
Upvotes: 1