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

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


    public void testConcatFunc2() {
        EntityManager em = currentEntityManager();
        startTx(em);

        CompUser user = em.find(CompUser.class, userid1);
        assertNotNull("the user is null", user);
        assertEquals("the users name is not seetha", user.getName(), "Seetha");

        String query = "UPDATE CompUser e " +
            "SET e.name = " +
            "CONCAT('', '') WHERE e.name='Seetha'";
        int result = em.createQuery(query).executeUpdate();

        assertEquals(1, result);

        user = em.find(CompUser.class, userid1);
        em.refresh(user);
        assertNotNull(user);
        // Empty strings are stored as null on Oracle so the assertion below
        // must be handled differently on that DB.  The docs indicate that
        // this may not be the case in future releases so either result is
        // allowed.
        // The note in this section of Oracle doc explains the behavior:
        // http://download.oracle.com/docs/cd/B14117_01/server.101/ +
        // b10759/sql_elements005.htm#sthref511
        DBDictionary dict = ((JDBCConfiguration) getEmf().getConfiguration())
            .getDBDictionaryInstance();
        if (dict instanceof OracleDictionary) {
            assertTrue(user.getName() == null ||
                "".equals(user.getName()));
        } else if (dict instanceof SybaseDictionary) {
            assertEquals(" ", user.getName());
        } else {
            assertEquals("", user.getName());
        }

        endTx(em);
        endEm(em);
    }
View Full Code Here


    public void testTrimFunc3() {
        EntityManager em = currentEntityManager();
        startTx(em);

        CompUser user = em.find(CompUser.class, userid2);
        assertNotNull(user);
        assertEquals(expectedShannonName, user.getName());

        String query = "UPDATE CompUser e SET " +
            "e.name = Trim(e.name) WHERE " +
            "e.name='Shannon '";
        int result = em.createQuery(query).executeUpdate();

        user = em.find(CompUser.class, userid2);
        em.refresh(user);
        assertNotNull(user);
        assertEquals("Shannon", user.getName());

        endTx(em);
        endEm(em);
    }
View Full Code Here

    public void testLowerFunc() {
        EntityManager em = currentEntityManager();
        startTx(em);

        CompUser user = em.find(CompUser.class, userid3);
        assertNotNull(user);
        assertEquals("Ugo", user.getName());

        String query = "UPDATE CompUser e SET " +
            "e.name = LOWER(e.name) WHERE e.name='Ugo'";

        int result = em.createQuery(query).executeUpdate();

        user = em.find(CompUser.class, userid3);
        em.refresh(user);
        assertNotNull(user);
        assertEquals("ugo", user.getName());

        endTx(em);
        endEm(em);
    }
View Full Code Here

        if (!dict.supportsCaseConversionForLob) {
            return;
        }
        startTx(em);

        CompUser user = em.find(CompUser.class, userid5);
        assertNotNull(user);
        assertEquals("Famzy", user.getName());

        String query = "UPDATE CompUser e SET e.name = LOWER(e.name) WHERE LOWER(e.nameAsLob)='famzy'";

        int result = em.createQuery(query).executeUpdate();

        user = em.find(CompUser.class, userid5);
        em.refresh(user);
        assertNotNull(user);
        assertEquals("famzy", user.getName());

        endTx(em);
        endEm(em);
    }
View Full Code Here

    public void testUpperFunc() {
        EntityManager em = currentEntityManager();
        startTx(em);

        CompUser user = em.find(CompUser.class, userid3);
        assertNotNull(user);
        assertEquals("Ugo", user.getName());

        String query = "UPDATE CompUser e SET " +
            "e.name = UPPER(e.name) WHERE e.name='Ugo'";

        int result = em.createQuery(query).executeUpdate();

        user = em.find(CompUser.class, userid3);
        em.refresh(user);
        assertNotNull(user);
        assertEquals("UGO", user.getName());

        endTx(em);
        endEm(em);
    }
View Full Code Here

        if (!dict.supportsCaseConversionForLob) {
            return;
        }
        startTx(em);

        CompUser user = em.find(CompUser.class, userid5);
        assertNotNull(user);
        assertEquals("Famzy", user.getName());

        String query = "UPDATE CompUser e SET e.name = UPPER(e.name) WHERE UPPER(e.nameAsLob)='FAMZY'";

        int result = em.createQuery(query).executeUpdate();

        user = em.find(CompUser.class, userid5);
        em.refresh(user);
        assertNotNull(user);
        assertEquals("FAMZY", user.getName());

        endTx(em);
        endEm(em);
    }
View Full Code Here

    public void testArithmFunc() {
        EntityManager em = currentEntityManager();
        startTx(em);

        CompUser user = em.find(CompUser.class, userid1);

        assertNotNull(user);
        assertEquals("Seetha", user.getName());
        assertEquals(36, user.getAge());

        String query =
            "UPDATE CompUser e SET e.age = ABS(e.age) WHERE e.name='Seetha'";
        int num = em.createQuery(query).executeUpdate();

        assertNotNull(num);
        assertEquals(1, num);

        user = em.find(CompUser.class, userid1);
        em.refresh(user);

        assertEquals(36, user.getAge());

        //----------------------ABS Tested

        query =
            "UPDATE CompUser e SET e.age = SQRT(e.age) WHERE e.name='Seetha'";
        num = em.createQuery(query).executeUpdate();

        assertNotNull(num);
        assertEquals(1, num);

        user = em.find(CompUser.class, userid1);
        em.refresh(user);

        assertEquals(6, user.getAge());

        //-------------------------SQRT Tested

        query =
            "UPDATE CompUser e SET e.age = MOD(e.age, 4) WHERE e.name='Seetha'";
        num = em.createQuery(query).executeUpdate();

        assertNotNull(num);
        assertEquals(1, num);

        user = em.find(CompUser.class, userid1);
        em.refresh(user);

        assertEquals(2, user.getAge());

        //-------------------------MOD Tested

        query = "SELECT e.name FROM CompUser e WHERE SIZE(e.nicknames) = 6";
        List result = em.createQuery(query).getResultList();
View Full Code Here

        endEm(em);
    }

    public CompUser createUser(String name, String cName, Address add, int age,
        boolean isMale) {
        CompUser user = null;
        if (isMale) {
            user = new MaleUser();
            user.setName(name);
            user.setComputerName(cName);
            user.setAddress(add);
            user.setAge(age);
            user.setNameAsLob(name);
        } else {
            user = new FemaleUser();
            user.setName(name);
            user.setComputerName(cName);
            user.setAddress(add);
            user.setAge(age);
            user.setNameAsLob(name);
        }
        return user;
    }
View Full Code Here

        super.setUp(CLEAR_TABLES, CompUser.class, MaleUser.class,
            FemaleUser.class, Address.class);
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        CompUser user = createUser(ORIGINAL_NAME, "PC", ORIGINAL_AGE, false);

        em.persist(user);

        em.getTransaction().commit();
        userid = user.getUserid();
        em.close();
    }
View Full Code Here

       
    }

    public CompUser createUser(String name, String cName, int age,
        boolean isMale) {
        CompUser user = null;
        Address addr = new Address("43 Sansome", "SF", "United-Kingdom",
                "94104");
        if (isMale) {
            user = new MaleUser();
            user.setName(name);
            user.setComputerName(cName);
            user.setAge(age);
        } else {
            user = new FemaleUser();
            user.setName(name);
            user.setComputerName(cName);
            user.setAge(age);
        }
        user.setAddress(addr);
        return user;
    }
View Full Code Here

TOP

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

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.