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

Examples of org.apache.openjpa.persistence.common.apps.Shirt


        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        int nPart = 3;
        tx.begin();

        Shirt shirt = new Shirt();
        String name = "Shirt: " + System.currentTimeMillis();
        shirt.setTxeName(name);
        String size = "L";
        shirt.setSzeId(size);
       
        int pid = (int) System.currentTimeMillis();
        for (int i = 0; i < nPart; i++) {
          Part part = new Part();
          part.setPartName("Part");
          part.getId().setPartNumber(pid++);
          part.setShirt(shirt);
          shirt.getParts().add(part);
        }
        em.persist(shirt);
        tx.commit();
        em.close();
       
        int sid = shirt.getTextileId();
        em = emf.createEntityManager();
        shirt = em.find(Shirt.class, sid);
        assertNotNull(shirt);
        assertNotNull(shirt.getParts());
        assertEquals(nPart, shirt.getParts().size());
       
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.common.apps.Shirt

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.