/**
   * This test will fail because JPA does an update before inserting the new records. The update
   * will set the foreign key to null, which violates the not null constraint.
   */
  @Test
  public void test_replace_collection_with_unidirectional_relation() {
    em.getTransaction().begin();
    Person p = em.find(Person.class, 201L);

    final ArrayList<Car> cars = new ArrayList<Car>();
    p.addCar(new Car("Ferrari"));

    p.setCars(cars);

    em.flush();
    em.getTransaction().commit();
  }