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

Examples of com.google.appengine.datanucleus.test.jpa.HasVersionMain


    Key mainKey = KeyFactory.createKey(HasVersionMain.class.getSimpleName(), 1);

    // Persist a Main
    em.getTransaction().begin();
    HasVersionMain m = new HasVersionMain(mainKey);
    em.persist(m);
    em.getTransaction().commit();
    em.close();

    // Add a Sub to the Main
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    HasVersionMain main = em.find(HasVersionMain.class, mainKey);
    HasVersionSub s = new HasVersionSub();
    s.setKey(mainKey, "Init db #0");
    main.getSubs().add(s);
    em.getTransaction().commit();
    em.close();

    // Get and detach Main (1)
    em = emf.createEntityManager();
    em.getTransaction().begin();
    HasVersionMain m1 = em.find(HasVersionMain.class, mainKey);
    m1.getSubs(); // Make sure subs are loaded
    HasVersionSub s1 = m1.getSubs().get(0);
    s1.getValue(); s1.getVersion();
    assertNotNull("Version on element is null", JDOHelper.getVersion(s1));
    em.getTransaction().commit();
    em.close();

    // Get and detach Main (2)
    em = emf.createEntityManager();
    em.getTransaction().begin();
    HasVersionMain m2 = em.find(HasVersionMain.class, mainKey);
    m2.getSubs(); // Make sure subs are loaded
    HasVersionSub s2 = m2.getSubs().get(0);
    s2.getValue(); s2.getVersion();
    assertNotNull("Version on element is null", JDOHelper.getVersion(s2));
    em.getTransaction().commit();
    em.close();
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.HasVersionMain

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.