Package com.google.appengine.datanucleus.test.jpa.UnownedUpgradeJPA

Examples of com.google.appengine.datanucleus.test.jpa.UnownedUpgradeJPA.SideB


  public void testOneToManyUpgrade() {
    switchDatasource(EntityManagerFactoryName.originalStorageVersion);

    // Do the writes with the relationship managed via Key
    SideB sideB1 = new SideB();
    sideB1.setName("yar");
    beginTxn();
    em.persist(sideB1);
    commitTxn();

    SideB sideB2 = new SideB();
    sideB2.setName("bar");
    beginTxn();
    em.persist(sideB2);
    commitTxn();

    HasOneToManyWithKey withKey = new HasOneToManyWithKey();
    withKey.addOther(KeyFactory.createKey("UnownedUpgradeJPA$SideB", sideB1.getId()));
    withKey.addOther(KeyFactory.createKey("UnownedUpgradeJPA$SideB", sideB2.getId()));
    beginTxn();
    em.persist(withKey);
    commitTxn();

    beginTxn();
    assertEquals(2, em.find(
        HasOneToManyWithKey.class, withKey.getId()).getOthers().size());
    commitTxn();

    Map<String, String> props = Utils.newHashMap();
    props.put("datanucleus.appengine.datastoreEnableXGTransactions", Boolean.TRUE.toString());
    props.put("datanucleus.appengine.storageVersion", StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN.name());
    switchDatasource(EntityManagerFactoryName.originalStorageVersion, props);
    // Now read it back as an unowned relationship
    beginTxn();
    HasOneToManyWithUnowned withUnowned =
        em.find(HasOneToManyWithUnowned.class, withKey.getId());
    assertEquals(2, withUnowned.getOthers().size());
    assertEquals(sideB1.getId(), withUnowned.getOthers().get(0).getId());
    assertEquals(sideB2.getId(), withUnowned.getOthers().get(1).getId());
    commitTxn();
  }
View Full Code Here


  public void testOneToOneUpgrade() throws EntityNotFoundException {
    switchDatasource(EntityManagerFactoryName.originalStorageVersion);

    // Do the writes with the relationship managed via Key
    SideB sideB1 = new SideB();
    sideB1.setName("yar");
    beginTxn();
    em.persist(sideB1);
    commitTxn();

    HasOneToOneWithKey withKey = new HasOneToOneWithKey();
    withKey.setOther(KeyFactory.createKey("UnownedUpgradeJPA$SideB", sideB1.getId()));
    beginTxn();
    em.persist(withKey);
    commitTxn();

    beginTxn();
    assertNotNull(em.find(HasOneToOneWithKey.class, withKey.getId()).getOther());
    commitTxn();

    Map<String, String> props = Utils.newHashMap();
    props.put("datanucleus.appengine.datastoreEnableXGTransactions", Boolean.TRUE.toString());
    props.put("datanucleus.appengine.storageVersion", StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN.name());
    switchDatasource(EntityManagerFactoryName.originalStorageVersion, props);

    // Now read it back as an unowned relationship
    beginTxn();
    HasOneToOneWithUnowned withUnowned = em.find(HasOneToOneWithUnowned.class, withKey.getId());
    assertNotNull(withUnowned.getOther());
    assertEquals(sideB1.getId(), withUnowned.getOther().getId());
    commitTxn();
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.UnownedUpgradeJPA.SideB

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.