Added entities and basic select

This commit is contained in:
Priyesh Mashelkar
2018-09-04 00:01:25 +01:00
parent a3f6ad6d88
commit 4798036089
3 changed files with 99 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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;
}
}