Package org.apache.openjpa.persistence.datacache.common.apps

Examples of org.apache.openjpa.persistence.datacache.common.apps.M2MEntityE


     */
    public void testM2MDataCache(){
      EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        M2MEntityE e1 = new M2MEntityE();
        e1.setId(1);
        e1.setName("ABC");
        em.persist(e1);
        M2MEntityE e2 = new M2MEntityE();
        e2.setId(2);
        e2.setName("DEF");
        em.persist(e2);
       
        M2MEntityF f1 = new M2MEntityF();
        f1.setId(10);
        em.persist(f1);
        M2MEntityF f2 = new M2MEntityF();
        f2.setId(20);
        em.persist(f2);
       
        e1.getEntityF().put(f1.getId(), f1);
        e1.getEntityF().put(f2.getId(), f2);
        e2.getEntityF().put(f1.getId(), f1);
        e2.getEntityF().put(f2.getId(), f2);
       
        f1.getEntityE().put(e1.getName(), e1);
        f1.getEntityE().put(e2.getName(), e2);
        f2.getEntityE().put(e1.getName(), e1);
        f2.getEntityE().put(e2.getName(), e2);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        try {
            M2MEntityE e1a = em.find(M2MEntityE.class, 1);
            Map entityf1 = e1a.getEntityF();
            M2MEntityE e2a = em.find(M2MEntityE.class, 2);
            Map entityf2 = e2a.getEntityF();
            M2MEntityF f1a = em.find(M2MEntityF.class, 10);
            Map entitye1 = f1a.getEntityE();
            M2MEntityF f2a = em.find(M2MEntityF.class, 20);
            Map entitye2 = f2a.getEntityE();
        } catch (Exception e) {
View Full Code Here


     */
    public void testM2MDataCache(){
      EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        M2MEntityE e1 = new M2MEntityE();
        e1.setId(1);
        e1.setName("ABC");
        em.persist(e1);
        M2MEntityE e2 = new M2MEntityE();
        e2.setId(2);
        e2.setName("DEF");
        em.persist(e2);
       
        M2MEntityF f1 = new M2MEntityF();
        f1.setId(10);
        em.persist(f1);
        M2MEntityF f2 = new M2MEntityF();
        f2.setId(20);
        em.persist(f2);
       
        e1.getEntityF().put(f1.getId(), f1);
        e1.getEntityF().put(f2.getId(), f2);
        e2.getEntityF().put(f1.getId(), f1);
        e2.getEntityF().put(f2.getId(), f2);
       
        f1.getEntityE().put(e1.getName(), e1);
        f1.getEntityE().put(e2.getName(), e2);
        f2.getEntityE().put(e1.getName(), e1);
        f2.getEntityE().put(e2.getName(), e2);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        M2MEntityE e1a = em.find(M2MEntityE.class, 1);
        Map entityf1 = e1a.getEntityF();
        M2MEntityE e2a = em.find(M2MEntityE.class, 2);
        Map entityf2 = e2a.getEntityF();
        M2MEntityF f1a = em.find(M2MEntityF.class, 10);
        Map entitye1 = f1a.getEntityE();
        M2MEntityF f2a = em.find(M2MEntityF.class, 20);
        Map entitye2 = f2a.getEntityE();
        em.close();
View Full Code Here

            CLEAR_TABLES);
    }

    public void populate(EntityManager em) {
        em.getTransaction().begin();
        M2MEntityE e1 = new M2MEntityE();
        e1.setId(1);
        e1.setName("ABC");
        em.persist(e1);
        M2MEntityE e2 = new M2MEntityE();
        e2.setId(2);
        e2.setName("DEF");
        em.persist(e2);

        M2MEntityF f1 = new M2MEntityF();
        f1.setId(10);
        em.persist(f1);
        M2MEntityF f2 = new M2MEntityF();
        f2.setId(20);
        em.persist(f2);

        e1.getEntityF().put(f1.getId(), f1);
        e1.getEntityF().put(f2.getId(), f2);
        e2.getEntityF().put(f1.getId(), f1);
        e2.getEntityF().put(f2.getId(), f2);

        f1.getEntityE().put(e1.getName(), e1);
        f1.getEntityE().put(e2.getName(), e2);
        f2.getEntityE().put(e1.getName(), e1);
        f2.getEntityE().put(e2.getName(), e2);
        em.getTransaction().commit();
    }
View Full Code Here

        EntityManager em = emf.createEntityManager();
        populate(em);
        em.close();

        em = emf.createEntityManager();
        M2MEntityE e1a = em.find(M2MEntityE.class, 1);
        assertNotNull(e1a.getEntityF());
        M2MEntityE e2a = em.find(M2MEntityE.class, 2);
        assertNotNull(e2a.getEntityF());
        M2MEntityF f1a = em.find(M2MEntityF.class, 10);
        assertNotNull(f1a.getEntityE());
        M2MEntityF f2a = em.find(M2MEntityF.class, 20);
        assertNotNull(f2a.getEntityE());
        em.close();
View Full Code Here

        OpenJPAEntityManager ojEm = OpenJPAPersistence.cast(em);
        ojEm.getFetchPlan().addField(M2MEntityE.class, "entityf");
        ojEm.getFetchPlan().addField(M2MEntityF.class, "entitye");

        M2MEntityE e1, e2;
        M2MEntityF f1, f2;

        e1 = em.find(M2MEntityE.class, 1);
        e2 = em.find(M2MEntityE.class, 2);
        f1 = em.find(M2MEntityF.class, 10);
View Full Code Here

     */
    public void testM2MDataCache(){
      EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        M2MEntityE e1 = new M2MEntityE();
        e1.setId(1);
        e1.setName("ABC");
        em.persist(e1);
        M2MEntityE e2 = new M2MEntityE();
        e2.setId(2);
        e2.setName("DEF");
        em.persist(e2);
       
        M2MEntityF f1 = new M2MEntityF();
        f1.setId(10);
        em.persist(f1);
        M2MEntityF f2 = new M2MEntityF();
        f2.setId(20);
        em.persist(f2);
       
        e1.getEntityF().put(f1.getId(), f1);
        e1.getEntityF().put(f2.getId(), f2);
        e2.getEntityF().put(f1.getId(), f1);
        e2.getEntityF().put(f2.getId(), f2);
       
        f1.getEntityE().put(e1.getName(), e1);
        f1.getEntityE().put(e2.getName(), e2);
        f2.getEntityE().put(e1.getName(), e1);
        f2.getEntityE().put(e2.getName(), e2);
        e1.print();
        e2.print();
        f1.print();
        f2.print();
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        M2MEntityE e1a = em.find(M2MEntityE.class, 1);
        M2MEntityE e2a = em.find(M2MEntityE.class, 2);
        M2MEntityF f1a = em.find(M2MEntityF.class, 10);
        M2MEntityF f2a = em.find(M2MEntityF.class, 20);
    }
View Full Code Here

     */
    public void testM2MDataCache() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        M2MEntityE e1 = new M2MEntityE();
        e1.setId(1);
        e1.setName("ABC");
        em.persist(e1);
        M2MEntityE e2 = new M2MEntityE();
        e2.setId(2);
        e2.setName("DEF");
        em.persist(e2);

        M2MEntityF f1 = new M2MEntityF();
        f1.setId(10);
        em.persist(f1);
        M2MEntityF f2 = new M2MEntityF();
        f2.setId(20);
        em.persist(f2);

        e1.getEntityF().put(f1.getId(), f1);
        e1.getEntityF().put(f2.getId(), f2);
        e2.getEntityF().put(f1.getId(), f1);
        e2.getEntityF().put(f2.getId(), f2);

        f1.getEntityE().put(e1.getName(), e1);
        f1.getEntityE().put(e2.getName(), e2);
        f2.getEntityE().put(e1.getName(), e1);
        f2.getEntityE().put(e2.getName(), e2);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        // check that we can find the entities and retrieve their map fields
View Full Code Here

     */
    public void testM2MDataCache(){
      EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        M2MEntityE e1 = new M2MEntityE();
        e1.setId(1);
        e1.setName("ABC");
        em.persist(e1);
        M2MEntityE e2 = new M2MEntityE();
        e2.setId(2);
        e2.setName("DEF");
        em.persist(e2);
       
        M2MEntityF f1 = new M2MEntityF();
        f1.setId(10);
        em.persist(f1);
        M2MEntityF f2 = new M2MEntityF();
        f2.setId(20);
        em.persist(f2);
       
        e1.getEntityF().put(f1.getId(), f1);
        e1.getEntityF().put(f2.getId(), f2);
        e2.getEntityF().put(f1.getId(), f1);
        e2.getEntityF().put(f2.getId(), f2);
       
        f1.getEntityE().put(e1.getName(), e1);
        f1.getEntityE().put(e2.getName(), e2);
        f2.getEntityE().put(e1.getName(), e1);
        f2.getEntityE().put(e2.getName(), e2);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        try {
            M2MEntityE e1a = em.find(M2MEntityE.class, 1);
            Map entityf1 = e1a.getEntityF();
            M2MEntityE e2a = em.find(M2MEntityE.class, 2);
            Map entityf2 = e2a.getEntityF();
            M2MEntityF f1a = em.find(M2MEntityF.class, 10);
            Map entitye1 = f1a.getEntityE();
            M2MEntityF f2a = em.find(M2MEntityF.class, 20);
            Map entitye2 = f2a.getEntityE();
        } catch (Exception e) {
View Full Code Here

     */
    public void testM2MDataCache(){
      EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        M2MEntityE e1 = new M2MEntityE();
        e1.setId(1);
        e1.setName("ABC");
        em.persist(e1);
        M2MEntityE e2 = new M2MEntityE();
        e2.setId(2);
        e2.setName("DEF");
        em.persist(e2);
       
        M2MEntityF f1 = new M2MEntityF();
        f1.setId(10);
        em.persist(f1);
        M2MEntityF f2 = new M2MEntityF();
        f2.setId(20);
        em.persist(f2);
       
        e1.getEntityF().put(f1.getId(), f1);
        e1.getEntityF().put(f2.getId(), f2);
        e2.getEntityF().put(f1.getId(), f1);
        e2.getEntityF().put(f2.getId(), f2);
       
        f1.getEntityE().put(e1.getName(), e1);
        f1.getEntityE().put(e2.getName(), e2);
        f2.getEntityE().put(e1.getName(), e1);
        f2.getEntityE().put(e2.getName(), e2);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        M2MEntityE e1a = em.find(M2MEntityE.class, 1);
        Map entityf1 = e1a.getEntityF();
        M2MEntityE e2a = em.find(M2MEntityE.class, 2);
        Map entityf2 = e2a.getEntityF();
        M2MEntityF f1a = em.find(M2MEntityF.class, 10);
        Map entitye1 = f1a.getEntityE();
        M2MEntityF f2a = em.find(M2MEntityF.class, 20);
        Map entitye2 = f2a.getEntityE();
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.datacache.common.apps.M2MEntityE

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.