I am working on a Spring Hibernate project where I have three classes
BaseEntity
, Person
& Owner
.
Person
extends BaseEntity
, Owner
extends Person
.
BaseEntity.java
public class BaseEntity {
private Integer id;
Getters & Setters
Person.java
public class Person extends BaseEntity {
private String firstName;
private String lastName;
Getters & Setters
Owner.java
@Entity
@Table(name="OWNERS")
public class Owner extends Person {
@Column(name="ADDRESS")
private String address;
@Column(name="CITY")
private String city;
@Column(name="TELEPHONE")
private String telephone;
Getter and Setters
Now I want to map all the properties of the three classes in a single table which
is Owner
. Can anyone please help me how do I map?
I have a xml based mapping for this & I want to do it in annotation
<class name="org.springframework.samples.petclinic.Owner" table="owners">
<id name="id" column="id">
<generator class="identity"/>
</id>
<property name="firstName" column="first_name"/>
<property name="lastName" column="last_name"/>
<property name="address" column="address"/>
<property name="city" column="city"/>
<property name="telephone" column="telephone"/>
</class>
I thought of using table per class inheritance mapping but here in xml I see no discriminator column being used.