Examples of PersonKVStore


Examples of com.impetus.client.oraclenosql.entities.PersonKVStore

        // roll back.
        em.getTransaction().rollback();

        em.getTransaction().begin();

        PersonKVStore p = findById(PersonKVStore.class, "1", em);
        Assert.assertNull(p);

        // on commit.
        em.getTransaction().commit();
View Full Code Here

Examples of com.impetus.client.oraclenosql.entities.PersonKVStore

        em.persist(p3);

        // on commit.
        em.getTransaction().commit();

        PersonKVStore p = findById(PersonKVStore.class, "1", em);
        Assert.assertNotNull(p);

        em.getTransaction().begin();

        ((PersonKVStore) p2).setPersonName("rollback");
        em.merge(p2);

        // roll back, should roll back person name for p2!
        em.getTransaction().rollback();

        p = findById(PersonKVStore.class, "1", em);
        Assert.assertNotNull(p);

        p = findById(PersonKVStore.class, "2", em);
        Assert.assertNotNull(p);
        Assert.assertEquals("vivek", p.getPersonName());
        Assert.assertNotSame("rollback", p.getPersonName());

    }
View Full Code Here

Examples of com.impetus.client.oraclenosql.entities.PersonKVStore

     *             the schema disagreement exception
     */
    @Test
    public void rollbackOnError() throws IOException
    {
        PersonKVStore p = null;
        try
        {
            Object p1 = prepareData("1", 10);
            Object p2 = prepareData("2", 20);
            em.persist(p1);
            em.persist(p2);

            p = findById(PersonKVStore.class, "1", em);
            Assert.assertNotNull(p);

            Object p3 = prepareData("3", 15);
            em.persist(p3);

            // Assert on rollback on error.
            ((PersonKVStore) p2).setPersonName("rollback");
            em.merge(p2);
            em.merge(null);

            // As this is a runtime exception so rollback should happen and
            // delete out commited data.
        }
        catch (Exception ex)
        {

            p = findById(PersonKVStore.class, "1", em);
            Assert.assertNull(p);

            p = findById(PersonKVStore.class, "2", em);
            Assert.assertNull(p);

            p = findById(PersonKVStore.class, "3", em);
            Assert.assertNull(p);
        }
        em.clear();
        // persist with 1 em
        EntityManager em1 = emf.createEntityManager();
        // em1.setFlushMode(FlushModeType.COMMIT);
        em1.getTransaction().begin();
        Object p3 = prepareData("4", 15);
        em1.persist(p3);
        em1.getTransaction().commit();

        try
        {
            // remove with another em with auto flush.
            EntityManager em2 = emf.createEntityManager();
            PersonKVStore person = em2.find(PersonKVStore.class, "4");
            em2.remove(person);
            em2.merge(null);
        }
        catch (Exception ex)
        {
View Full Code Here

Examples of com.impetus.client.oraclenosql.entities.PersonKVStore

        EntityManager em2 = emf.createEntityManager();
        // em2.setFlushMode(FlushModeType.COMMIT);

        // begin transaction.
        em2.getTransaction().begin();
        PersonKVStore found = em2.find(PersonKVStore.class, "11");
        found.setPersonName("merged");
        em2.merge(found);

        // commit p1 after modification.
        em2.getTransaction().commit();

        // open another entity manager.
        EntityManager em3 = emf.createEntityManager();
        found = em3.find(PersonKVStore.class, "11");
        found.setPersonName("lastemerge");
        try
        {
            em3.merge(found);
            em3.merge(null);
        }
        catch (Exception ex)
        {
            PersonKVStore finalFound = em2.find(PersonKVStore.class, "11");
            Assert.assertNotNull(finalFound);
            Assert.assertEquals("merged", finalFound.getPersonName());
        }
    }
View Full Code Here

Examples of com.impetus.client.oraclenosql.entities.PersonKVStore

     *            the age
     * @return the person
     */
    private PersonKVStore prepareData(String rowKey, int age)
    {
        PersonKVStore o = new PersonKVStore();
        o.setPersonId(rowKey);
        o.setPersonName("vivek");
        o.setAge(age);
        return o;
    }
View Full Code Here

Examples of com.impetus.client.oraclenosql.entities.PersonKVStore

        persistPerson("3", "person3", 30);
        persistPerson("4", "person4", 40);

        // Find Records
        clearEm();
        PersonKVStore p11 = findById("1");
        assertNotNull(p11);
        assertEquals("person1", p11.getPersonName());
        assertEquals(10, p11.getAge());

        PersonKVStore p22 = findById("2");
        assertNotNull(p22);
        assertEquals("person2", p22.getPersonName());
        assertEquals(20, p22.getAge());

        PersonKVStore p33 = findById("3");
        assertNotNull(p33);
        assertEquals("person3", p33.getPersonName());
        assertEquals(30, p33.getAge());

        PersonKVStore p44 = findById("4");
        assertNotNull(p44);
        assertEquals("person4", p44.getPersonName());
        assertEquals(40, p44.getAge());

        PersonKVStore p55 = findById("5"); // Invalid records
        Assert.assertNull(p55);

        // Update records
        p11.setPersonName("person11");
        p11.setAge(100);
View Full Code Here

Examples of com.impetus.client.oraclenosql.entities.PersonKVStore

        persist(p);
    }

    protected PersonKVStore preparePerson(String rowKey, int age, String name)
    {
        PersonKVStore person = new PersonKVStore();
        person.setPersonId(rowKey);
        person.setPersonName(name);
        person.setAge(age);
        return person;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.