Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cfo2K4u4rF18QsPXPFnytf
64 lines
1.2 KiB
Java
64 lines
1.2 KiB
Java
package lab.hibernate.model;
|
|
|
|
import jakarta.persistence.*;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
@Entity
|
|
public class Employee {
|
|
@Id
|
|
@GeneratedValue
|
|
public Long id;
|
|
public String name;
|
|
public int salary;
|
|
|
|
/** Owning side of the association, lazy on purpose. */
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
public Department department;
|
|
|
|
@Embedded
|
|
public Address address;
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
public Level level = Level.JUNIOR;
|
|
|
|
@ManyToMany
|
|
public Set<Project> projects = new HashSet<>();
|
|
|
|
protected Employee() {}
|
|
|
|
public Employee(String name, int salary, Department department) {
|
|
this.name = name;
|
|
this.salary = salary;
|
|
this.department = department;
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public int getSalary() {
|
|
return salary;
|
|
}
|
|
|
|
public Department getDepartment() {
|
|
return department;
|
|
}
|
|
|
|
public Address getAddress() {
|
|
return address;
|
|
}
|
|
|
|
public Level getLevel() {
|
|
return level;
|
|
}
|
|
|
|
public Set<Project> getProjects() {
|
|
return projects;
|
|
}
|
|
}
|