@Test public void shouldPersistWithFlush() throws Exception { Customer customer = new Customer("Anthony", "Balla", "aballa@mail.com"); Address address = new Address("Ritherdon Rd", "London", "8QE", "UK"); customer.setAddress(address); assertThrows(IllegalStateException.class, () -> { tx.begin(); em.persist(customer); em.flush(); em.persist(address); tx.commit(); }); }
public void setAddress(Address address) { this.address = address; }
Customer { public void setAddress(Address address) { this.address = address; } }
Customer { public void setAddress(Address address) { this.address = address; } Customer();  Customer(String firstName, String lastName, String email); }
Customer { public void setAddress(Address address) { this.address = address; } Customer();  Customer(String firstName, String lastName, String email); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEmail(String email); Address getAddress(); void setAddress(Address address); }
Customer { public void setAddress(Address address) { this.address = address; } Customer();  Customer(String firstName, String lastName, String email); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEmail(String email); Address getAddress(); void setAddress(Address address);  }