祖先と子孫 (ツリーのような関係) を持つ階層エンティティをモデル化したいと考えています。より詳細には、エンティティ (ノード) には、1 つの親と、同じクラスの任意の数の子があります。次のコードは有効で健全ですか、それともこれを実装するためのより良い方法はありますか? fetch アノテーションは、this.ProductClass を親として持つノードの数に応じて、子 Set が自動的に満たされることを意味しますか?
@NodeEntity
public class ProductClass {
@GraphId
private Long id;
@Indexed
private String name;
private String leveltype;
private String description;
@Fetch
@RelatedTo(type = "PARENT", direction = Direction.INCOMING)
Set<ProductClass> children;
@RelatedTo(type = "PARENT", direction = Direction.OUTGOING)
ProductClass parent;