I want to use Java Persistence to create multiple tables that share a subset of columns but can't figure out the magic syntax.
@Data
@NoArgsConstructor
public class SubClass extends Auditable {
@Column(name = "foo")
private String foo;
}
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "A")
public class SuperClassA extends SubClass{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int lorum;
}
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "B")
public class SuperClassB extends SubClass{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int ipsum;
}
The end result of this would be two tables
Table A with fields lorum
and foo
and
Table B with fields ipsum
and foo