我遇到了一些问题。下面定义了一个父类和从父类派生的子类。由于父类具有@Table注释,我可以定义索引。但是由于子类中没有@Table注释,我该如何为该子类列定义索引呢?我想使用@SecondaryTable注释,但是我认为@InheritanceType.SINGLE_TABLE无用,因为会创建另一个子表。如果我有任何错误,请纠正。另外,是否有解决子级索引问题的方法。
@Table(name = "Parent", indexes = {@Index(name = "IDX_USERNAME", columnList = "username")})
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE")
@Entity
public class Parent{
}
@Entity
@DiscriminatorValue("C")
public class Child extends Parent{
}