View Javadoc
1   package fr.tiogars.chat.domains.nomenclature.entities;
2   
3   import fr.tiogars.chat.domains.taxonomy.AuditedTaxonomyEntity;
4   import jakarta.persistence.Entity;
5   import jakarta.persistence.Table;
6   import jakarta.persistence.ManyToOne;
7   import jakarta.persistence.FetchType;
8   
9   @Entity
10  @Table(name = "nomenclatures")
11  public class NomenclatureEntity extends AuditedTaxonomyEntity {
12      @ManyToOne(fetch = FetchType.LAZY)
13      private NomenclatureEntity parent;
14  
15      protected NomenclatureEntity() {
16          // Required by JPA.
17      }
18  
19      public NomenclatureEntity(String code, String label, String description) {
20          super(code, label, description);
21      }
22  
23      public NomenclatureEntity getParent() {
24          return parent;
25      }
26  
27      public void setParent(NomenclatureEntity parent) {
28          this.parent = parent;
29      }
30  
31      public Long getParentId() {
32          return parent == null ? null : parent.getId();
33      }
34  }