Added entities and basic select
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.hibernate.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
@Entity
|
||||
public class Department {
|
||||
@Id
|
||||
long id;
|
||||
String name;
|
||||
@OneToMany(mappedBy="department")
|
||||
List<Employee> employees;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.baeldung.hibernate.entities;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class Employee {
|
||||
@Id
|
||||
long id;
|
||||
String employeeNumber;
|
||||
String name;
|
||||
String designation;
|
||||
@ManyToOne
|
||||
Department department;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getEmployeeNumber() {
|
||||
return employeeNumber;
|
||||
}
|
||||
public void setEmployeeNumber(String employeeNumber) {
|
||||
this.employeeNumber = employeeNumber;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDesignation() {
|
||||
return designation;
|
||||
}
|
||||
public void setDesignation(String designation) {
|
||||
this.designation = designation;
|
||||
}
|
||||
public Department getDepartment() {
|
||||
return department;
|
||||
}
|
||||
public void setDepartment(Department department) {
|
||||
this.department = department;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user