getters and setters removed from code

This commit is contained in:
Kingsley Amankwah 2023-04-30 15:53:49 +05:30
parent 1767ea3cdc
commit d650f7ace7
5 changed files with 116 additions and 5 deletions

View File

@ -16,9 +16,27 @@ public class Course {
inverseJoinColumns = @JoinColumn(name = "student_id"))
private List<Student> students;
public List<Student> getStudents() {
public List<Student> getStudents() {
return students;
}
//getters and setters
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setStudents(List<Student> students) {
this.students = students;
}
}

View File

@ -15,5 +15,28 @@ public class Employee {
@JoinColumn(name = "department_id")
private Department department;
//getters and setters
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
}

View File

@ -14,7 +14,30 @@ public class Student {
@ManyToMany(mappedBy = "students")
private List<Course> courses;
// getters and setters
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Course> getCourses() {
return courses;
}
public void setCourses(List<Course> courses) {
this.courses = courses;
}
}

View File

@ -14,4 +14,27 @@ public class Author {
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "authors")
private Set<Book> books;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Book> getBooks() {
return books;
}
public void setBooks(Set<Book> books) {
this.books = books;
}
}

View File

@ -1,4 +1,5 @@
package com.baeldung.associations.unidirectional;
import jakarta.persistence.*;
import java.util.Set;
@ -17,4 +18,27 @@ public class Book {
inverseJoinColumns = @JoinColumn(name = "author_id"))
private Set<Author> authors;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Set<Author> getAuthors() {
return authors;
}
public void setAuthors(Set<Author> authors) {
this.authors = authors;
}
}