Examples of Lobs


Examples of org.apache.openjpa.persistence.kernel.common.apps.Lobs

    // lob tests

    public void testLobPersistQuery() {
        // test with null
        EntityManager em = emf.createEntityManager();
        Lobs lobs = new Lobs();
        em.getTransaction().begin();
        lobs.setLobNotNullable("test");
        lobs.setLobNullable(null);
        em.persist(lobs);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        em.getTransaction().begin();
        Query query = em.createQuery("select e from Lobs e");
        lobs = (Lobs)query.getSingleResult();
        // Oracle treats "" as null
        assertTrue(lobs.getLobNullable() == null || lobs.getLobNullable().length() == 0);   // still an empty string
        em.remove(lobs);
        em.getTransaction().commit();
        em.close();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.Lobs

    }
   
    public void testLobSetToNull() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        Lobs lobs = new Lobs();
        lobs.setLobNotNullable(null);
        lobs.setLobNullable(null);
        em.persist(lobs);
        try {
            em.getTransaction().commit();
            fail("Expected a RollbackException");
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.Lobs

    }
  
    public void testLobEmptyString() {
        // test with ""
        EntityManager em = emf.createEntityManager();
        Lobs lobs = new Lobs();
        em.getTransaction().begin();
        lobs.setLobNullable("");
        em.persist(lobs);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        em.getTransaction().begin();
        Query query = em.createQuery("select e from Lobs e");
        lobs = (Lobs)query.getSingleResult();
       
        if (lobs.getLobNullable() != null) {
            if (getDBDictionary() instanceof SybaseDictionary) {
                // Sybase stores empty strings as " "
                assertEquals(" ", lobs.getLobNullable());
            } else {
                assertEquals(0, lobs.getLobNullable().length());
            }
        }
        if (lobs.getLobNotNullable() != null) {
            if (getDBDictionary() instanceof SybaseDictionary) {
                // Sybase stores empty strings as " "
                assertEquals(" ", lobs.getLobNotNullable());
            } else {
                assertEquals(0, lobs.getLobNotNullable().length());
            }
        }
        assertEquals(lobs.getLobNullable(), lobs.getLobNotNullable());
        em.remove(lobs);
        em.getTransaction().commit();
        em.close();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.Lobs

        String temp = "";
        for (int i = 0; i < 500; i++) // at 400 it changes from strings to Objects
            temp = temp + "1234567890";

        EntityManager em = emf.createEntityManager();
        Lobs lobs = new Lobs();
        em.getTransaction().begin();
        lobs.setLobNotNullable(temp);
        lobs.setLobNullable(temp);
        em.persist(lobs);
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        em.getTransaction().begin();
        Query query = em.createQuery("select e from Lobs e");
        lobs = (Lobs)query.getSingleResult();
        assertEquals(lobs.getLobNullable(), lobs.getLobNotNullable());
        assertEquals(temp, lobs.getLobNullable());
        em.remove(lobs);
        em.getTransaction().commit();
        em.close();
    }
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.