Aspect Ratio of a JPA Object

can someone help me understand how I can define an object with a JPA mapping that has a relationship with it?

For example, my entity is CompanyDivision, divA contains division B, splitC and division B contains division B1, division B2

  • divisionA
    • divisionB
      • divisionB1
      • divisionB2
    • divisionC

Thanks!

0
map jpa entity relation parentid
source share
1 answer

It is no different from the relationship between two different entities. Here is an example:

class CompanyDivision { @OneToMany(mappedBy = "parentDivision") private Set<CompanyDivision> childDivisions = new HashSet<CompanyDivision>(); @ManyToOne @JoinColumn(name = "FK_PARENT_DIVISION") private CompanyDivision parentDivision; } 
+4
source share

All Articles