1 package myorg.relex.collection;
2
3 import java.util.Collections;
4 import java.util.LinkedList;
5 import java.util.List;
6
7 import javax.persistence.*;
8
9
10
11
12
13 @Entity
14 @Table(name="RELATIONEX_PATH")
15 public class Path {
16 @Id @GeneratedValue
17 private int id;
18
19 @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
20 @JoinColumn
21 @OrderBy("number ASC")
22 private List<Segment> segments;
23
24 @Column(length=16)
25 private String name;
26
27 public int getId() { return id; }
28
29 public List<Segment> getSegments() {
30 if (segments==null) { segments = new LinkedList<Segment>(); }
31 return segments;
32 }
33
34
35 public Path addSegment(Segment segment) {
36 getSegments().add(segment);
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 Collections.sort(segments);
53 return this;
54 }
55
56 public String getName() { return name; }
57 public void setName(String name) {
58 this.name = name;
59 }
60 }