Reputation: 983
I have a Entity B that extends entity A
public Class A {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
....
}
public Class B extends A {
private String name;
}
When Look into database I see that only table A is created and have both fields from Class A and Class B. I need to create separate table for Class B. How can I do that?
P.S I tried some answers from here stackoverflow but they didn't help me
Upvotes: 0
Views: 91
Reputation: 983
This should work
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class B extends A{
}
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class InterestBaseSettings {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
.....
}
Tested works!
Delete old tables and allow Hibernate to create tables himself.
Upvotes: 1