-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProperty.java
More file actions
81 lines (68 loc) · 2.25 KB
/
Copy pathProperty.java
File metadata and controls
81 lines (68 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.martincastroalvarez.london;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.GenerationType;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="properties")
public class Property {
// --------------------------------------------------------------------
// Property Model.
//
// This model represents a Property in the application that can own
// be bought by Persons.
// --------------------------------------------------------------------
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@JoinColumn(name="fk_owner", nullable=false)
@ManyToOne(optional=false, cascade=CascadeType.ALL, fetch=FetchType.EAGER)
private Person owner;
private String name;
public void Property() {}
public void Property(Long id, String name, Person owner) {
this.id = id;
this.owner = owner;
this.name = name;
}
public Long getId() { return id; }
public Person getOwner() { return owner; }
public void setOwner(Person owner) { this.owner = owner; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Property other = (Property) obj;
if (!Objects.equals(this.name, other.name)) {
return false;
}
if (!this.getOwner().equals(other.getOwner())) {
return false;
}
return Objects.equals(this.id, other.id);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Property{");
sb.append("id=").append(id);
sb.append(", owner='").append(owner.getName()).append('\'');
sb.append(", name='").append(name).append('\'');
sb.append('}');
return sb.toString();
}
}