Reputation: 6622
I have several table sharing n columns, so I think the best strategy would be making an abstract class with InheritanceType=TABLE_PER_CLASS. Problem is that, even though columns are exactly the same, they could go by a different name.
For example:
T1
--name varchar(100)
--surname varchar(50)
T2
--person_name varchar(100)
--person_surname varchar(100)
Columns are the same, type is the same..but name is different! So, is there a way to define an abstract parent class:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Parent{
private String name;
private String surname;
}
and then, inside of children entities, specify the actual column name?
Upvotes: 1
Views: 58
Reputation: 603
What you need is to add the following to the child entity:
@AttributeOverrides({
@AttributeOverride(name="name", column=@Column(name="person_name")),
@AttributeOverride(name="surname", column=@Column(name="person_surname"))
})
Upvotes: 1