Commit 5af14f61 by Patryk Czarnik

Wygenerowanie klas na podstawie bazy w IDEA

parent 17c4a920
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="hr@localhost" uuid="69a0b1e1-6916-48d8-97e3-4c1a6e46c2b2">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://localhost:5432/hr</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="postgres@vps" uuid="b334493d-3cc6-4ff8-aa28-6740ee00ea9c">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://vps-2bc225bd.vps.ovh.net:5432/hr</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
\ No newline at end of file
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package hr.model;
import jakarta.persistence.*;
@Entity
@Table(name = "countries")
public class Country {
@Id
@Column(name = "country_id", nullable = false, length = 2)
private String countryId;
@Column(name = "country_name", length = 40)
private String countryName;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "region_id")
private hr.model.Region region;
public String getCountryId() {
return countryId;
}
public void setCountryId(String countryId) {
this.countryId = countryId;
}
public String getCountryName() {
return countryName;
}
public void setCountryName(String countryName) {
this.countryName = countryName;
}
public hr.model.Region getRegion() {
return region;
}
public void setRegion(hr.model.Region region) {
this.region = region;
}
}
\ No newline at end of file
package hr.model;
import jakarta.persistence.*;
import org.hibernate.annotations.ColumnDefault;
import java.util.LinkedHashSet;
import java.util.Set;
@Entity
@Table(name = "departments")
public class Department {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ColumnDefault("nextval('departments_seq')")
@Column(name = "department_id", nullable = false)
private Integer id;
@Column(name = "department_name", nullable = false, length = 100)
private String departmentName;
@Column(name = "manager_id")
private Integer managerId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "location_id")
private hr.model.Location location;
@OneToMany(mappedBy = "department")
private Set<Integer> employees = new LinkedHashSet<>();
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public Integer getManagerId() {
return managerId;
}
public void setManagerId(Integer managerId) {
this.managerId = managerId;
}
public hr.model.Location getLocation() {
return location;
}
public void setLocation(hr.model.Location location) {
this.location = location;
}
public Set<Integer> getEmployees() {
return employees;
}
public void setEmployees(Set<Integer> employees) {
this.employees = employees;
}
}
\ No newline at end of file
package hr.model;
import jakarta.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDate;
@Entity
@Table(name = "employees")
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "employees_id_gen")
@SequenceGenerator(name = "employees_id_gen", sequenceName = "employees_seq", initialValue = 207, allocationSize = 1)
@Column(name = "employee_id", nullable = false)
private Integer id;
@Column(name = "first_name", length = 25)
private String firstName;
@Column(name = "last_name", nullable = false, length = 30)
private String lastName;
@Column(name = "email", nullable = false, length = 30)
private String email;
@Column(name = "phone_number", length = 20)
private String phoneNumber;
@Column(name = "hire_date", nullable = false)
private LocalDate hireDate;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "job_id", nullable = false)
private hr.model.Job job;
@Column(name = "salary", precision = 8, scale = 2)
private BigDecimal salary;
@Column(name = "commission_pct", precision = 2, scale = 2)
private BigDecimal commissionPct;
@Column(name = "manager_id")
private Integer manager;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "department_id")
private Department department;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public LocalDate getHireDate() {
return hireDate;
}
public void setHireDate(LocalDate hireDate) {
this.hireDate = hireDate;
}
public hr.model.Job getJob() {
return job;
}
public void setJob(hr.model.Job job) {
this.job = job;
}
public BigDecimal getSalary() {
return salary;
}
public void setSalary(BigDecimal salary) {
this.salary = salary;
}
public BigDecimal getCommissionPct() {
return commissionPct;
}
public void setCommissionPct(BigDecimal commissionPct) {
this.commissionPct = commissionPct;
}
public Integer getManager() {
return manager;
}
public void setManager(Integer manager) {
this.manager = manager;
}
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
}
\ No newline at end of file
package hr.model;
import jakarta.persistence.*;
import java.math.BigDecimal;
import java.util.LinkedHashSet;
import java.util.Set;
@Entity
@Table(name = "jobs")
public class Job {
@Id
@SequenceGenerator(name = "jobs_id_gen", sequenceName = "employees_seq", initialValue = 207, allocationSize = 1)
@Column(name = "job_id", nullable = false, length = 10)
private String jobId;
@Column(name = "job_title", nullable = false, length = 35)
private String jobTitle;
@Column(name = "min_salary", precision = 8, scale = 2)
private BigDecimal minSalary;
@Column(name = "max_salary", precision = 8, scale = 2)
private BigDecimal maxSalary;
@OneToMany(mappedBy = "job")
private Set<Integer> employees = new LinkedHashSet<>();
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getJobTitle() {
return jobTitle;
}
public void setJobTitle(String jobTitle) {
this.jobTitle = jobTitle;
}
public BigDecimal getMinSalary() {
return minSalary;
}
public void setMinSalary(BigDecimal minSalary) {
this.minSalary = minSalary;
}
public BigDecimal getMaxSalary() {
return maxSalary;
}
public void setMaxSalary(BigDecimal maxSalary) {
this.maxSalary = maxSalary;
}
public Set<Integer> getEmployees() {
return employees;
}
public void setEmployees(Set<Integer> employees) {
this.employees = employees;
}
}
\ No newline at end of file
package hr.model;
import jakarta.persistence.*;
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)
@EmbeddedId
private JobHistoryId id;
@MapsId("employeeId")
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "employee_id", nullable = false)
private Integer 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;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "department_id")
private Department department;
public JobHistoryId getId() {
return id;
}
public void setId(JobHistoryId id) {
this.id = id;
}
public Integer getEmployee() {
return employee;
}
public void setEmployee(Integer employee) {
this.employee = employee;
}
public LocalDate getEndDate() {
return endDate;
}
public void setEndDate(LocalDate endDate) {
this.endDate = endDate;
}
public hr.model.Job getJob() {
return job;
}
public void setJob(hr.model.Job job) {
this.job = job;
}
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
}
\ No newline at end of file
package hr.model;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import org.hibernate.Hibernate;
import java.time.LocalDate;
import java.util.Objects;
@Embeddable
public class JobHistoryId implements java.io.Serializable {
private static final long serialVersionUID = 7844257974829568247L;
@Column(name = "employee_id", nullable = false)
private Integer employeeId;
@Column(name = "start_date", nullable = false)
private LocalDate startDate;
public Integer getEmployeeId() {
return employeeId;
}
public void setEmployeeId(Integer employeeId) {
this.employeeId = employeeId;
}
public LocalDate getStartDate() {
return startDate;
}
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
JobHistoryId entity = (JobHistoryId) o;
return Objects.equals(this.employeeId, entity.employeeId) &&
Objects.equals(this.startDate, entity.startDate);
}
@Override
public int hashCode() {
return Objects.hash(employeeId, startDate);
}
}
\ No newline at end of file
package hr.model;
import jakarta.persistence.*;
import org.hibernate.annotations.ColumnDefault;
@Entity
@Table(name = "locations")
public class Location {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ColumnDefault("nextval('locations_seq')")
@Column(name = "location_id", nullable = false)
private Integer id;
@Column(name = "street_address", length = 40)
private String streetAddress;
@Column(name = "postal_code", length = 12)
private String postalCode;
@Column(name = "city", nullable = false, length = 30)
private String city;
@Column(name = "state_province", length = 25)
private String stateProvince;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "country_id")
private Country country;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getStreetAddress() {
return streetAddress;
}
public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getStateProvince() {
return stateProvince;
}
public void setStateProvince(String stateProvince) {
this.stateProvince = stateProvince;
}
public Country getCountry() {
return country;
}
public void setCountry(Country country) {
this.country = country;
}
}
\ No newline at end of file
package hr.model;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "regions")
public class Region {
@Id
@Column(name = "region_id", nullable = false)
private Integer id;
@Column(name = "region_name", length = 25)
private String regionName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getRegionName() {
return regionName;
}
public void setRegionName(String regionName) {
this.regionName = regionName;
}
}
\ No newline at end of file
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