Package org.springframework.data.jpa.domain.sample

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


   * @see DATAJPA-50
   */
  @Test
  public void executesCrudOperationsForEntityWithIdClass() {

    PersistableWithIdClass entity = new PersistableWithIdClass(1L, 1L);
    idClassRepository.save(entity);

    assertThat(entity.getFirst(), is(notNullValue()));
    assertThat(entity.getSecond(), is(notNullValue()));

    PersistableWithIdClassPK id = new PersistableWithIdClassPK(entity.getFirst(), entity.getSecond());

    assertThat(idClassRepository.findOne(id), is(entity));
  }
View Full Code Here


   * @see DATAJPA-266
   */
  @Test
  public void testExistsForDomainObjectsWithCompositeKeys() throws Exception {

    PersistableWithIdClass s1 = idClassRepository.save(new PersistableWithIdClass(1L, 1L));
    PersistableWithIdClass s2 = idClassRepository.save(new PersistableWithIdClass(2L, 2L));

    assertThat(idClassRepository.exists(s1.getId()), is(true));
    assertThat(idClassRepository.exists(s2.getId()), is(true));
    assertThat(idClassRepository.exists(new PersistableWithIdClassPK(1L, 2L)), is(false));
  }
View Full Code Here

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

    PersistableWithIdClass entity = new PersistableWithIdClass(1L, 1L);
    idClassRepository.save(entity);

    assertThat(entity.getFirst(), is(notNullValue()));
    assertThat(entity.getSecond(), is(notNullValue()));

    PersistableWithIdClassPK id = new PersistableWithIdClassPK(entity.getFirst(), entity.getSecond());

    assertThat(idClassRepository.exists(id), is(true));
  }
View Full Code Here

   * @see DATAJPA-50
   */
  @Test
  public void returnsIdInstanceCorrectly() {

    PersistableWithIdClass entity = new PersistableWithIdClass(2L, 4L);

    JpaEntityInformation<PersistableWithIdClass, ?> information = JpaEntityInformationSupport.getMetadata(
        PersistableWithIdClass.class, em);
    Object id = information.getId(entity);

View Full Code Here

  public void doesNotCreateIdIfAllPartialAttributesAreNull() {

    JpaMetamodelEntityInformation<PersistableWithIdClass, Serializable> information = new JpaMetamodelEntityInformation<PersistableWithIdClass, Serializable>(
        PersistableWithIdClass.class, metamodel);

    PersistableWithIdClass entity = new PersistableWithIdClass(null, null);
    assertThat(information.getId(entity), is(nullValue()));

    entity = new PersistableWithIdClass(2L, null);
    assertThat(information.getId(entity), is(notNullValue()));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.jpa.domain.sample.PersistableWithIdClass

Copyright © 2018 www.massapicom. 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.