Examples of IdClassExampleDepartment


Examples of org.springframework.data.jpa.domain.sample.IdClassExampleDepartment

   * @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()));
  }
View Full Code Here

Examples of org.springframework.data.jpa.domain.sample.IdClassExampleDepartment

      // we expect this test to fail on 4.1.x - due to a bug in hibernate - remove as soon as 4.1.x fixes the issue.
      expectedException.expect(InvalidDataAccessApiUsageException.class);
      expectedException.expectMessage("No supertype found");
    }

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

    IdClassExampleEmployee emp = new IdClassExampleEmployee();
    emp.setDepartment(dep);
    emp = employeeRepositoryWithIdClass.save(emp);
View Full Code Here

Examples of org.springframework.data.jpa.domain.sample.IdClassExampleDepartment

   * @see DATAJPA-497
   */
  @Test
  public void sortByEmbeddedPkFieldInCompositePkWithIdClassInQueryDsl() {

    IdClassExampleDepartment dep1 = new IdClassExampleDepartment();
    dep1.setDepartmentId(1L);
    dep1.setName("Dep1");

    IdClassExampleDepartment dep2 = new IdClassExampleDepartment();
    dep2.setDepartmentId(2L);
    dep2.setName("Dep2");

    IdClassExampleEmployee emp1 = new IdClassExampleEmployee();
    emp1.setEmpId(3L);
    emp1.setDepartment(dep2);
    emp1 = employeeRepositoryWithIdClass.save(emp1);

    IdClassExampleEmployee emp2 = new IdClassExampleEmployee();
    emp2.setEmpId(2L);
    emp2.setDepartment(dep1);
    emp2 = employeeRepositoryWithIdClass.save(emp2);

    IdClassExampleEmployee emp3 = new IdClassExampleEmployee();
    emp3.setEmpId(1L);
    emp3.setDepartment(dep2);
    emp3 = employeeRepositoryWithIdClass.save(emp3);

    QIdClassExampleEmployee emp = QIdClassExampleEmployee.idClassExampleEmployee;
    List<IdClassExampleEmployee> result = employeeRepositoryWithIdClass.findAll(
        emp.department.departmentId.eq(dep2.getDepartmentId()), emp.empId.asc());

    assertThat(result, is(notNullValue()));
    assertThat(result, hasSize(2));
    assertThat(result.get(0), is(emp3));
    assertThat(result.get(1), is(emp1));
View Full Code Here

Examples of org.springframework.data.jpa.domain.sample.IdClassExampleDepartment

   * @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));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.