Package org.apache.openejb.test.entity.cmp

Examples of org.apache.openejb.test.entity.cmp.BasicCmpBean


    }

    private void cmpText() throws Exception {
        beginTx();

        BasicCmpBean basicCmpBean = new BasicCmpBean_Subclass();
        basicCmpBean.ejbCreateObject("Joe Blow");
        assertFalse(entityManager.contains(basicCmpBean));

        entityManager.persist(basicCmpBean);

        // extract primary key seems to require a flush followed by a merge
        entityManager.flush();
        basicCmpBean = entityManager.merge(basicCmpBean);
        int joeId = basicCmpBean.getPrimaryKey();

        assertTrue(entityManager.contains(basicCmpBean));

        commitTx();
        beginTx();

        basicCmpBean = new BasicCmpBean_Subclass();
        basicCmpBean.ejbCreateObject("Lloyd Dobler");
        assertFalse(entityManager.contains(basicCmpBean));

        entityManager.persist(basicCmpBean);

        // extract primary key seems to require a flush followed by a merge
        entityManager.flush();
        basicCmpBean = entityManager.merge(basicCmpBean);
        int lloydId = basicCmpBean.getPrimaryKey();

        assertTrue(entityManager.contains(basicCmpBean));
        commitTx();


        beginTx();

        BasicCmpBean joe = (BasicCmpBean) entityManager.createQuery("select e from BasicCmpBean_Subclass e where e.primaryKey=" + joeId).getSingleResult();
        assertTrue(entityManager.contains(joe));

        assertEquals(joe.getPrimaryKey(), joeId);
        assertEquals(joe.getFirstName(), "Joe");
        assertEquals(joe.getLastName(), "Blow");

        BasicCmpBean lloyd = (BasicCmpBean) entityManager.createQuery("select e from BasicCmpBean_Subclass e where e.primaryKey=" + lloydId).getSingleResult();
        assertTrue(entityManager.contains(lloyd));

        assertEquals(lloyd.getPrimaryKey(), lloydId);
        assertEquals(lloyd.getFirstName(), "Lloyd");
        assertEquals(lloyd.getLastName(), "Dobler");

        commitTx();
    }
View Full Code Here


    }

    private void cmpText() throws Exception {
        beginTx();

        BasicCmpBean basicCmpBean = new BasicCmpBean_Subclass();
        basicCmpBean.ejbCreateObject("Joe Blow");
        assertFalse(entityManager.contains(basicCmpBean));

        entityManager.persist(basicCmpBean);

        // extract primary key seems to require a flush followed by a merge
        entityManager.flush();
        basicCmpBean = entityManager.merge(basicCmpBean);
        final int joeId = basicCmpBean.getPrimaryKey();

        assertTrue(entityManager.contains(basicCmpBean));

        commitTx();
        beginTx();

        basicCmpBean = new BasicCmpBean_Subclass();
        basicCmpBean.ejbCreateObject("Lloyd Dobler");
        assertFalse(entityManager.contains(basicCmpBean));

        entityManager.persist(basicCmpBean);

        // extract primary key seems to require a flush followed by a merge
        entityManager.flush();
        basicCmpBean = entityManager.merge(basicCmpBean);
        final int lloydId = basicCmpBean.getPrimaryKey();

        assertTrue(entityManager.contains(basicCmpBean));
        commitTx();


        beginTx();

        final BasicCmpBean joe = (BasicCmpBean) entityManager.createQuery("select e from BasicCmpBean_Subclass e where e.primaryKey=" + joeId).getSingleResult();
        assertTrue(entityManager.contains(joe));

        assertEquals(joe.getPrimaryKey(), joeId);
        assertEquals(joe.getFirstName(), "Joe");
        assertEquals(joe.getLastName(), "Blow");

        final BasicCmpBean lloyd = (BasicCmpBean) entityManager.createQuery("select e from BasicCmpBean_Subclass e where e.primaryKey=" + lloydId).getSingleResult();
        assertTrue(entityManager.contains(lloyd));

        assertEquals(lloyd.getPrimaryKey(), lloydId);
        assertEquals(lloyd.getFirstName(), "Lloyd");
        assertEquals(lloyd.getLastName(), "Dobler");

        commitTx();
    }
View Full Code Here

    }

    private void cmpText() throws Exception {
        beginTx();

        BasicCmpBean basicCmpBean = new BasicCmpBean_Subclass();
        basicCmpBean.ejbCreateObject("Joe Blow");
        assertFalse(entityManager.contains(basicCmpBean));

        entityManager.persist(basicCmpBean);

        // extract primary key seems to require a flush followed by a merge
        entityManager.flush();
        basicCmpBean = entityManager.merge(basicCmpBean);
        int joeId = basicCmpBean.getPrimaryKey();

        assertTrue(entityManager.contains(basicCmpBean));

        commitTx();
        beginTx();

        basicCmpBean = new BasicCmpBean_Subclass();
        basicCmpBean.ejbCreateObject("Lloyd Dobler");
        assertFalse(entityManager.contains(basicCmpBean));

        entityManager.persist(basicCmpBean);

        // extract primary key seems to require a flush followed by a merge
        entityManager.flush();
        basicCmpBean = entityManager.merge(basicCmpBean);
        int lloydId = basicCmpBean.getPrimaryKey();

        assertTrue(entityManager.contains(basicCmpBean));
        commitTx();


        beginTx();

        BasicCmpBean joe = (BasicCmpBean) entityManager.createQuery("select e from BasicCmpBean_Subclass e where e.primaryKey=" + joeId).getSingleResult();
        assertTrue(entityManager.contains(joe));

        assertEquals(joe.getPrimaryKey(), joeId);
        assertEquals(joe.getFirstName(), "Joe");
        assertEquals(joe.getLastName(), "Blow");

        BasicCmpBean lloyd = (BasicCmpBean) entityManager.createQuery("select e from BasicCmpBean_Subclass e where e.primaryKey=" + lloydId).getSingleResult();
        assertTrue(entityManager.contains(lloyd));

        assertEquals(lloyd.getPrimaryKey(), lloydId);
        assertEquals(lloyd.getFirstName(), "Lloyd");
        assertEquals(lloyd.getLastName(), "Dobler");

        commitTx();
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.test.entity.cmp.BasicCmpBean

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.