| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
package org.directdemocracyportal.democracy.model.world; |
| 6 | |
|
| 7 | |
import java.util.HashSet; |
| 8 | |
import java.util.Set; |
| 9 | |
|
| 10 | |
import javax.persistence.CascadeType; |
| 11 | |
import javax.persistence.Entity; |
| 12 | |
import javax.persistence.FetchType; |
| 13 | |
import javax.persistence.JoinColumn; |
| 14 | |
import javax.persistence.ManyToOne; |
| 15 | |
import javax.persistence.OneToMany; |
| 16 | |
|
| 17 | |
import org.directdemocracyportal.democracy.model.core.Environment; |
| 18 | |
import org.hibernate.annotations.Cache; |
| 19 | |
import org.hibernate.annotations.CacheConcurrencyStrategy; |
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
@Entity |
| 25 | |
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) |
| 26 | |
public class Region extends Environment |
| 27 | |
{ |
| 28 | |
|
| 29 | |
|
| 30 | |
private static final long serialVersionUID = 614889376820015758L; |
| 31 | |
|
| 32 | |
|
| 33 | |
private Region parent; |
| 34 | |
|
| 35 | |
|
| 36 | |
private RegionType regionType; |
| 37 | |
|
| 38 | |
|
| 39 | 2 | private Set<Region> parts = new HashSet<Region>(); |
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | 2 | public Region() { |
| 45 | 2 | } |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
@ManyToOne |
| 53 | |
@JoinColumn |
| 54 | |
public Region getParent() { |
| 55 | 0 | return parent; |
| 56 | |
} |
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
public void setParent(Region parent) { |
| 64 | 0 | this.parent = parent; |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.LAZY) |
| 73 | |
public Set<Region> getParts() { |
| 74 | 0 | return parts; |
| 75 | |
} |
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
public void setParts(Set<Region> parts) { |
| 83 | 0 | this.parts = parts; |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
public RegionType getRegionType() { |
| 92 | 0 | return regionType; |
| 93 | |
} |
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
public void setRegionType(RegionType regionType) { |
| 101 | 0 | this.regionType = regionType; |
| 102 | 0 | } |
| 103 | |
} |