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:
Josh Cummings
2018-10-02 07:22:12 -06:00
committed by GitHub
parent 52c2ce4ede
commit 9a085b0e8f
3 changed files with 61 additions and 4 deletions

View File

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

View File

@@ -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")