父类
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class OnlinePost {
@Id
@SequenceGenerator(
name = "onlinePost_sequence",
sequenceName = "onlinePost_sequence",
allocationSize = 1
)
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "onlinePost_sequence"
)
private Long postId;
// some other columns, getters and setters
}
子类别
public class Post extends OnlinePost{
private String image;
private String title;
}
我要删除父元素,然后自动删除子元素
2条答案
按热度按时间b09cbbtk1#
您可以执行以下操作。
删除父项时执行此操作。子项将自动删除
2vuwiymt2#
在父类中创建一个子字段,然后Map两个类并在关系中应用级联类型删除,以获得所需的输出示例: