-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathPet.java
77 lines (59 loc) · 2.05 KB
/
Pet.java
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
package com.haulmont.sample.petclinic.entity.pet;
import com.haulmont.chile.core.annotations.NamePattern;
import com.haulmont.sample.petclinic.entity.NamedEntity;
import com.haulmont.sample.petclinic.entity.owner.Owner;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
@NamePattern("%s - %s|identificationNumber,name")
@Table(name = "PETCLINIC_PET", uniqueConstraints = {
@UniqueConstraint(name = "IDX_PETCLINIC_PET_ID_UNQ", columnNames = {"IDENTIFICATION_NUMBER", "DELETE_TS"})
})
@Entity(name = "petclinic_Pet")
public class Pet extends NamedEntity {
private static final long serialVersionUID = -3431453457784831240L;
@NotNull
@Column(name = "IDENTIFICATION_NUMBER", nullable = false)
protected String identificationNumber;
@Column(name = "BIRTH_DATE")
protected LocalDate birthDate;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TYPE_ID")
protected PetType type;
@NotNull
@Column(name = "GENERATION", nullable = false)
protected Integer generation;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "OWNER_ID")
protected Owner owner;
public Generation getGeneration() {
return generation == null ? null : Generation.fromId(generation);
}
public void setGeneration(Generation generation) {
this.generation = generation == null ? null : generation.getId();
}
public void setBirthDate(LocalDate birthDate) {
this.birthDate = birthDate;
}
public LocalDate getBirthDate() {
return birthDate;
}
public void setIdentificationNumber(String identificationNumber) {
this.identificationNumber = identificationNumber;
}
public String getIdentificationNumber() {
return identificationNumber;
}
public void setOwner(Owner owner) {
this.owner = owner;
}
public Owner getOwner() {
return owner;
}
public void setType(PetType type) {
this.type = type;
}
public PetType getType() {
return type;
}
}