Examples of EmbeddedIdExampleDepartment


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

   * @see Final JPA 2.0 Specification 2.4.1.3 Derived Identities Example 3
   */
  @Test
  public void shouldSupportSavingEntitiesWithCompositeKeyClassesWithEmbeddedIdsAndDerivedIdentities() {

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

    EmbeddedIdExampleEmployee emp = new EmbeddedIdExampleEmployee();
    emp.setDepartment(dep);
    emp.setEmployeePk(new EmbeddedIdExampleEmployeePK());

    emp = employeeRepositoryWithEmbeddedId.save(emp);

    EmbeddedIdExampleEmployeePK key = new EmbeddedIdExampleEmployeePK();
    key.setDepartmentId(emp.getDepartment().getDepartmentId());
    key.setEmployeeId(emp.getEmployeePk().getEmployeeId());
    EmbeddedIdExampleEmployee persistedEmp = employeeRepositoryWithEmbeddedId.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.EmbeddedIdExampleDepartment

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

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

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

    EmbeddedIdExampleEmployee emp1 = new EmbeddedIdExampleEmployee();
    emp1.setEmployeePk(new EmbeddedIdExampleEmployeePK(3L, null));
    emp1.setDepartment(dep2);
    emp1 = employeeRepositoryWithEmbeddedId.save(emp1);

    EmbeddedIdExampleEmployee emp2 = new EmbeddedIdExampleEmployee();
    emp2.setEmployeePk(new EmbeddedIdExampleEmployeePK(2L, null));
    emp2.setDepartment(dep1);
    emp2 = employeeRepositoryWithEmbeddedId.save(emp2);

    EmbeddedIdExampleEmployee emp3 = new EmbeddedIdExampleEmployee();
    emp3.setEmployeePk(new EmbeddedIdExampleEmployeePK(1L, null));
    emp3.setDepartment(dep2);
    emp3 = employeeRepositoryWithEmbeddedId.save(emp3);

    QEmbeddedIdExampleEmployee emp = QEmbeddedIdExampleEmployee.embeddedIdExampleEmployee;
    List<EmbeddedIdExampleEmployee> result = employeeRepositoryWithEmbeddedId.findAll(
        emp.employeePk.departmentId.eq(dep2.getDepartmentId()), emp.employeePk.employeeId.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.EmbeddedIdExampleDepartment

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

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

    EmbeddedIdExampleEmployeePK key = new EmbeddedIdExampleEmployeePK();
    key.setDepartmentId(1L);
    key.setEmployeeId(1L);

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.