0

我处理 OO 已经好几年了,有时我会看到一个类,它有一个属性(通常是列表或表),它包含对自身和其他相同类型对象的引用。

这种模式有名字吗?使用它的通常情况是什么,为什么?

提前谢谢。

4

1 回答 1

0

It is a very usual case. For instance a table which contains a foreign key to itself :

Employee
----------
ID
MANAGER_ID (reference to employee)

Your JPA/Hibernate entities will hold references to themselves when you are your own boss :-)

于 2013-06-14T15:43:21.830 回答