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 javax.persistence.*;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import static dst.ass1.jpa.util.Constants.*;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Organization implements IOrganization {
|
public class Organization implements IOrganization {
|
||||||
@Id
|
@Id @GeneratedValue private Long id;
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE)
|
|
||||||
private Long id;
|
|
||||||
private String name;
|
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;
|
private Collection<IOrganization> parts;
|
||||||
@ManyToMany(mappedBy = "parts")
|
|
||||||
|
@ManyToMany(mappedBy = "parts", targetEntity = Organization.class)
|
||||||
private Collection<IOrganization> partOf;
|
private Collection<IOrganization> partOf;
|
||||||
|
|
||||||
|
@ManyToMany(targetEntity = Vehicle.class)
|
||||||
|
private Collection<IVehicle> vehicles;
|
||||||
|
|
||||||
|
@OneToMany(targetEntity = Employment.class)
|
||||||
|
private Collection<IEmployment> employments;
|
||||||
|
|
||||||
public Organization() {
|
public Organization() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user