Mastering Java EE Development with WildFly
上QQ阅读APP看书,第一时间看更新

Cascading the one-to-one delete operation

The CascadeType.REMOVE is also inherited from the CascadeType.ALL configuration, so the Post entity deletion triggers a PostDetails entity removal too:

Info info = entityManager.find(Info.class, 1L);
entityManager.remove(info);

The remove generates the following operations:

delete from InfoDetails where id = 1
delete from Info where id = 1