Grails:扩展和嵌入域有什么区别 class?

Grails: What is the difference between extending and embedding a domain class?

我是 Grails 框架的新手,所以请多多包涵。

尽管如此,我对扩展域 class 和嵌入对象之间的功能差异感到有点困惑。
从数据库的角度来看,它们都做同样的事情。嵌入对象时,所有 classes 的所有属性都存储在一个 table 中。类似地,当扩展 class(使用 table-per-hierarchy)时,所有 classes 的所有属性都存储在一个 table 中。

我确定这两者之间存在功能差异,所以我想我会问这个问题。
你什么时候使用其中一个?

唯一的技术差异是在扩展 class 时每个子 table 属性 能够拥有多个 table 的能力。否则,它们在使用上是相同的。

然而,也就是说,通过扩展另一个 class,您也在 class 结构中对其进行建模,因此您可以利用 Java/Groovy 的 instanceof 和多态特性。