/** @see DATAJPA-527 */
  @Test
  public void testExistsWithIdClass() {

    IdClassExampleDepartment dep = new IdClassExampleDepartment();
    dep.setName("TestDepartment");
    dep.setDepartmentId(-1);

    IdClassExampleEmployee emp = new IdClassExampleEmployee();
    emp.setDepartment(dep);

    employeeRepositoryWithIdClass.save(emp);

    IdClassExampleEmployeePK key = new IdClassExampleEmployeePK();
    key.setDepartment(dep.getDepartmentId());
    key.setEmpId(emp.getEmpId());

    assertThat(employeeRepositoryWithIdClass.exists(key), is(true));
  }
  /**
   * @see DATAJPA-269
   * @see Final JPA 2.0 Specification 2.4.1.3 Derived Identities Example 2
   */
  @Test
  public void shouldSupportSavingEntitiesWithCompositeKeyClassesWithIdClassAndDerivedIdentities() {

    IdClassExampleDepartment dep = new IdClassExampleDepartment();
    dep.setName("TestDepartment");
    dep.setDepartmentId(-1);

    IdClassExampleEmployee emp = new IdClassExampleEmployee();
    emp.setDepartment(dep);

    employeeRepositoryWithIdClass.save(emp);

    IdClassExampleEmployeePK key = new IdClassExampleEmployeePK();
    key.setDepartment(dep.getDepartmentId());
    key.setEmpId(emp.getEmpId());
    IdClassExampleEmployee persistedEmp = employeeRepositoryWithIdClass.findOne(key);

    assertThat(persistedEmp, is(notNullValue()));
    assertThat(persistedEmp.getDepartment(), is(notNullValue()));
    assertThat(persistedEmp.getDepartment().getName(), is(dep.getName()));
  }