Package org.springframework.data.mongodb.crossstore.test

Examples of org.springframework.data.mongodb.crossstore.test.Person


    resume.addEducation("Skanstulls High School, 1975");
    resume.addEducation("Univ. of Stockholm, 1980");
    resume.addJob("DiMark, DBA, 1990-2000");
    resume.addJob("VMware, Developer, 2007-");

    final Person person = new Person("Thomas", 20);
    person.setAddress(address);
    person.setResume(resume);
    person.setId(1L);

    txTemplate.execute(new TransactionCallback<Void>() {
      public Void doInTransaction(TransactionStatus status) {
        entityManager.persist(person);
        return null;
View Full Code Here


  @Test
  @Transactional
  public void testReadJpaToMongoEntityRelationship() {

    Person found = entityManager.find(Person.class, 1L);
    Assert.assertNotNull(found);
    Assert.assertEquals(Long.valueOf(1), found.getId());
    Assert.assertNotNull(found);
    Assert.assertEquals(Long.valueOf(1), found.getId());
    Assert.assertNotNull(found.getResume());
    Assert.assertEquals("DiMark, DBA, 1990-2000" + "; " + "VMware, Developer, 2007-", found.getResume().getJobs());
  }
View Full Code Here

  @Test
  @Transactional
  public void testUpdatedJpaToMongoEntityRelationship() {

    Person found = entityManager.find(Person.class, 1L);
    found.setAge(44);
    found.getResume().addJob("SpringDeveloper.com, Consultant, 2005-2006");

    entityManager.merge(found);

    Assert.assertNotNull(found);
    Assert.assertEquals(Long.valueOf(1), found.getId());
    Assert.assertNotNull(found);
    Assert.assertEquals(Long.valueOf(1), found.getId());
    Assert.assertNotNull(found.getResume());
    Assert.assertEquals("DiMark, DBA, 1990-2000" + "; " + "VMware, Developer, 2007-" + "; "
        + "SpringDeveloper.com, Consultant, 2005-2006", found.getResume().getJobs());
  }
View Full Code Here

  }

  @Test
  public void testMergeJpaEntityWithMongoDocument() {

    final Person detached = entityManager.find(Person.class, 1L);
    entityManager.detach(detached);
    detached.getResume().addJob("TargetRx, Developer, 2000-2005");

    Person merged = txTemplate.execute(new TransactionCallback<Person>() {
      public Person doInTransaction(TransactionStatus status) {
        Person result = entityManager.merge(detached);
        entityManager.flush();
        return result;
      }
    });

    Assert.assertTrue(detached.getResume().getJobs().contains("TargetRx, Developer, 2000-2005"));
    Assert.assertTrue(merged.getResume().getJobs().contains("TargetRx, Developer, 2000-2005"));
    final Person updated = entityManager.find(Person.class, 1L);
    Assert.assertTrue(updated.getResume().getJobs().contains("TargetRx, Developer, 2000-2005"));
  }
View Full Code Here

  @Test
  public void testRemoveJpaEntityWithMongoDocument() {

    txTemplate.execute(new TransactionCallback<Person>() {
      public Person doInTransaction(TransactionStatus status) {
        Person p2 = new Person("Thomas", 20);
        Resume r2 = new Resume();
        r2.addEducation("Skanstulls High School, 1975");
        r2.addJob("DiMark, DBA, 1990-2000");
        p2.setResume(r2);
        p2.setId(2L);
        entityManager.persist(p2);
        Person p3 = new Person("Thomas", 20);
        Resume r3 = new Resume();
        r3.addEducation("Univ. of Stockholm, 1980");
        r3.addJob("VMware, Developer, 2007-");
        p3.setResume(r3);
        p3.setId(3L);
        entityManager.persist(p3);
        return null;
      }
    });
    txTemplate.execute(new TransactionCallback<Person>() {
      public Person doInTransaction(TransactionStatus status) {
        final Person found2 = entityManager.find(Person.class, 2L);
        entityManager.remove(found2);
        return null;
      }
    });
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.crossstore.test.Person

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.