Polish Session.load Tests (#5378)
Cleaned up some confusing wording and a confusing test. Added two more tests for demonstrating how session.load works with associations. Issue: BAEL-2126
This commit is contained in:
@@ -2,7 +2,9 @@ package com.baeldung.hibernate.proxy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
public class Company implements Serializable {
|
||||
@@ -14,6 +16,10 @@ public class Company implements Serializable {
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@OneToMany
|
||||
@JoinColumn(name = "workplace_id")
|
||||
private Set<Employee> employees = new HashSet<>();
|
||||
|
||||
public Company() { }
|
||||
|
||||
public Company(String name) {
|
||||
@@ -36,6 +42,10 @@ public class Company implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Set<Employee> getEmployees() {
|
||||
return this.employees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -15,6 +15,7 @@ public class Employee implements Serializable {
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "workplace_id")
|
||||
private Company workplace;
|
||||
|
||||
@Column(name = "first_name")
|
||||
|
||||
Reference in New Issue
Block a user