Commit 861f7763 by Patryk Czarnik

Zmiany w wygenerowanych klasach

parent 5af14f61
package hr.model;
/** Wspólna nadklasa dla wszystkich klas encji w tym pakiecie. Miejsce na dodatkowe metody. */
abstract class AbstractEntity {
public String hello() {
return "hello";
}
}
......@@ -4,7 +4,7 @@ import jakarta.persistence.*;
@Entity
@Table(name = "countries")
public class Country {
public class Country extends AbstractEntity {
@Id
@Column(name = "country_id", nullable = false, length = 2)
private String countryId;
......
......@@ -8,7 +8,7 @@ import java.util.Set;
@Entity
@Table(name = "departments")
public class Department {
public class Department extends AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ColumnDefault("nextval('departments_seq')")
......@@ -26,7 +26,7 @@ public class Department {
private hr.model.Location location;
@OneToMany(mappedBy = "department")
private Set<Integer> employees = new LinkedHashSet<>();
private Set<Employee> employees = new LinkedHashSet<>();
public Integer getId() {
return id;
......@@ -60,11 +60,11 @@ public class Department {
this.location = location;
}
public Set<Integer> getEmployees() {
public Set<Employee> getEmployees() {
return employees;
}
public void setEmployees(Set<Integer> employees) {
public void setEmployees(Set<Employee> employees) {
this.employees = employees;
}
......
......@@ -7,7 +7,7 @@ import java.time.LocalDate;
@Entity
@Table(name = "employees")
public class Employee {
public class Employee extends AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "employees_id_gen")
@SequenceGenerator(name = "employees_id_gen", sequenceName = "employees_seq", initialValue = 207, allocationSize = 1)
......
......@@ -8,9 +8,8 @@ import java.util.Set;
@Entity
@Table(name = "jobs")
public class Job {
public class Job extends AbstractEntity {
@Id
@SequenceGenerator(name = "jobs_id_gen", sequenceName = "employees_seq", initialValue = 207, allocationSize = 1)
@Column(name = "job_id", nullable = false, length = 10)
private String jobId;
......@@ -24,7 +23,7 @@ public class Job {
private BigDecimal maxSalary;
@OneToMany(mappedBy = "job")
private Set<Integer> employees = new LinkedHashSet<>();
private Set<Employee> employees = new LinkedHashSet<>();
public String getJobId() {
return jobId;
......@@ -58,11 +57,11 @@ public class Job {
this.maxSalary = maxSalary;
}
public Set<Integer> getEmployees() {
public Set<Employee> getEmployees() {
return employees;
}
public void setEmployees(Set<Integer> employees) {
public void setEmployees(Set<Employee> employees) {
this.employees = employees;
}
......
......@@ -6,22 +6,21 @@ import java.time.LocalDate;
@Entity
@Table(name = "job_history")
public class JobHistory {
@SequenceGenerator(name = "job_history_id_gen", sequenceName = "employees_seq", initialValue = 207, allocationSize = 1)
public class JobHistory extends AbstractEntity {
@EmbeddedId
private JobHistoryId id;
@MapsId("employeeId")
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "employee_id", nullable = false)
private Integer employee;
private Employee employee;
@Column(name = "end_date", nullable = false)
private LocalDate endDate;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "job_id", nullable = false)
private hr.model.Job job;
private Job job;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "department_id")
......@@ -35,11 +34,11 @@ public class JobHistory {
this.id = id;
}
public Integer getEmployee() {
public Employee getEmployee() {
return employee;
}
public void setEmployee(Integer employee) {
public void setEmployee(Employee employee) {
this.employee = employee;
}
......@@ -51,11 +50,11 @@ public class JobHistory {
this.endDate = endDate;
}
public hr.model.Job getJob() {
public Job getJob() {
return job;
}
public void setJob(hr.model.Job job) {
public void setJob(Job job) {
this.job = job;
}
......
......@@ -5,7 +5,7 @@ import org.hibernate.annotations.ColumnDefault;
@Entity
@Table(name = "locations")
public class Location {
public class Location extends AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ColumnDefault("nextval('locations_seq')")
......
......@@ -7,7 +7,7 @@ import jakarta.persistence.Table;
@Entity
@Table(name = "regions")
public class Region {
public class Region extends AbstractEntity {
@Id
@Column(name = "region_id", nullable = false)
private Integer id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment