*Fix indentation
This commit is contained in:
parent
195ab64929
commit
4955a87440
@ -10,10 +10,7 @@ public class Employee {
|
|||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
@CollectionTable(
|
@CollectionTable(name = "employee_phone", joinColumns = @JoinColumn(name = "employee_id"))
|
||||||
name = "employee_phone",
|
|
||||||
joinColumns = @JoinColumn(name = "employee_id")
|
|
||||||
)
|
|
||||||
private List<Phone> phones;
|
private List<Phone> phones;
|
||||||
|
|
||||||
public Employee() {
|
public Employee() {
|
||||||
|
@ -51,9 +51,8 @@ public class Phone {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Phone phone = (Phone) o;
|
Phone phone = (Phone) o;
|
||||||
return getType().equals(phone.getType()) &&
|
return getType().equals(phone.getType()) && getAreaCode().equals(phone.getAreaCode())
|
||||||
getAreaCode().equals(phone.getAreaCode()) &&
|
&& getNumber().equals(phone.getNumber());
|
||||||
getNumber().equals(phone.getNumber());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,7 +32,8 @@ public class EmployeeRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Employee findByJPQL(int id) {
|
public Employee findByJPQL(int id) {
|
||||||
return em.createQuery("SELECT u FROM Employee AS u JOIN FETCH u.phones WHERE u.id=:id", Employee.class).setParameter("id", id).getSingleResult();
|
return em.createQuery("SELECT u FROM Employee AS u JOIN FETCH u.phones WHERE u.id=:id", Employee.class)
|
||||||
|
.setParameter("id", id).getSingleResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Employee findByEntityGraph(int id) {
|
public Employee findByEntityGraph(int id) {
|
||||||
|
@ -27,7 +27,8 @@ public class ElementCollectionIntegrationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
Employee employee = new Employee(1, "Fred");
|
Employee employee = new Employee(1, "Fred");
|
||||||
employee.setPhones(Arrays.asList(new Phone("work", "+55", "99999-9999"), new Phone("home", "+55", "98888-8888")));
|
employee.setPhones(
|
||||||
|
Arrays.asList(new Phone("work", "+55", "99999-9999"), new Phone("home", "+55", "98888-8888")));
|
||||||
employeeRepository.save(employee);
|
employeeRepository.save(employee);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user