Package com.impetus.kundera.query

Examples of com.impetus.kundera.query.Person


    @Test
    public void testIsLoadedWithoutReference()
    {
        PersistenceUnitUtil utils = emf.getPersistenceUnitUtil();
       
        Person p = new Person();
        p.setAge(32);
        p.setPersonId("1");
     
        Assert.assertNotNull(utils);
        Assert.assertTrue(utils.isLoaded(p, "personId"));
        Assert.assertFalse(utils.isLoaded(null, "personName"));
    }
View Full Code Here


    @Test
    public void testGetIdentifier()
    {
        PersistenceUnitUtil utils = emf.getPersistenceUnitUtil();
       
        Person p = new Person();
        p.setAge(32);
        p.setPersonId("1");
       
        Assert.assertNotNull(utils.getIdentifier(p));
        Assert.assertEquals("1",utils.getIdentifier(p));
    }
View Full Code Here

    @Test
    public void testInvalidEntity()
    {
        PersistenceUnitUtil utils = emf.getPersistenceUnitUtil();
       
        Person p = new Person();
        p.setAge(32);
        p.setPersonId("1");
       
        try
        {
            utils.getIdentifier(new String("test"));
            Assert.fail("Should have gone to catch block!");
View Full Code Here

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

        em.getTransaction().begin();

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

        em.getTransaction().commit();

        // Still no record should be flushed as already rollback!
View Full Code Here

        em.persist(p3);

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

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

        em.getTransaction().begin();

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

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

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

        p = findById(Person.class, "2", em);
        Assert.assertNotNull(p);
        Assert.assertEquals("vivek", p.getPersonName());
        Assert.assertNotSame("rollback", p.getPersonName());
    }
View Full Code Here

    }

    @Test
    public void testRollbackOnError()
    {
        Person p = null;
        try
        {
            Object p1 = prepareData("1", 10);
            Object p2 = prepareData("2", 20);
            em.persist(p1);
            em.persist(p2);

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

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

            // Assert on rollback on error.
            ((Person) 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(Person.class, "1", em);
            Assert.assertNull(p);

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

            p = findById(Person.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();
            Person person = em2.find(Person.class, "4");
            em2.remove(person);
            em2.merge(null);
        }
        catch (Exception ex)
        {
View Full Code Here

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

        // begin transaction.
        em2.getTransaction().begin();
        Person found = em2.find(Person.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(Person.class, "11");
        found.setPersonName("lastemerge");
        try
        {
            em3.merge(found);
            em3.merge(null);
        }
        catch (Exception ex)
        {
            Person finalFound = em2.find(Person.class, "11");
            Assert.assertNotNull(finalFound);
            Assert.assertEquals("merged", finalFound.getPersonName());
        }
    }
View Full Code Here

        DummyDatabase.INSTANCE.dropDatabase();
    }

    private Person prepareData(String rowKey, int age)
    {
        Person o = new Person();
        o.setPersonId(rowKey);
        o.setPersonName("vivek");
        o.setAge(age);
        return o;
    }
View Full Code Here

{

    @Test
    public void test()
    {
        Person p = new Person();
        SearchResult result = new SearchResult();
       
        result.setPrimaryKey(p.getPersonId());
        result.setEmbeddedColumnName("none");
        result.addEmbeddedColumnValue("embeddedcolumn1");
        result.addEmbeddedColumnValue("embeddedcolumn2");
       
        Assert.assertNull(result.getPrimaryKey());
View Full Code Here

{

    @Test
    public void test()
    {
        Person p = new Person();
       
        List<String> columns = new ArrayList<String>();
        columns.add("column1");
        columns.add("column2");
        columns.add("column3");
View Full Code Here

TOP

Related Classes of com.impetus.kundera.query.Person

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.