I have an abstract class User
which is extended by RegularUser
and BusinessUser
. The tables in MySQL are RegularUser
and BusinessUser
. I created the abstract User
class as both RegularUser
and BusinessUser
contain similar data.
So if I were to have the Id annotation in the User
class like so:
public abstract class User {
@Id
@Column(name="id")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long userId;
// ...
}
And the Entity/table declaration in the BusinessUser
and RegularUser
classes like this:
@Entity
@Table(name="BUSINESS_USER")
public class BusinessUser extends User {
// ...
}
and this:
@Entity
@Table(name="REGULAR_USER")
public class RegularUser extends User {
// ...
}
Would this work properly? Or do both declarations need to be in the same class? Is this possible/allowed? I'm simply a bit confused on how to approach this.