Model Organization self reference
This commit is contained in:
parent
0f8a8d5f9f
commit
200eb6efd4
@ -7,17 +7,30 @@ import dst.ass1.jpa.model.IVehicle;
|
||||
import javax.persistence.*;
|
||||
import java.util.Collection;
|
||||
|
||||
import static dst.ass1.jpa.util.Constants.*;
|
||||
|
||||
@Entity
|
||||
public class Organization implements IOrganization {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE)
|
||||
private Long id;
|
||||
@Id @GeneratedValue private Long id;
|
||||
private String name;
|
||||
@ManyToMany
|
||||
|
||||
@ManyToMany(targetEntity = Organization.class)
|
||||
@JoinTable(
|
||||
name = J_ORGANIZATION_PARTS,
|
||||
joinColumns = @JoinColumn(name = I_ORGANIZATION_PART_OF),
|
||||
inverseJoinColumns = @JoinColumn(name = I_ORGANIZATION_PARTS)
|
||||
)
|
||||
private Collection<IOrganization> parts;
|
||||
@ManyToMany(mappedBy = "parts")
|
||||
|
||||
@ManyToMany(mappedBy = "parts", targetEntity = Organization.class)
|
||||
private Collection<IOrganization> partOf;
|
||||
|
||||
@ManyToMany(targetEntity = Vehicle.class)
|
||||
private Collection<IVehicle> vehicles;
|
||||
|
||||
@OneToMany(targetEntity = Employment.class)
|
||||
private Collection<IEmployment> employments;
|
||||
|
||||
public Organization() {
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user