Package org.apache.openjpa.persistence

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI


            closeEMF(tempEMF);
        }
    }
   
    protected void setSupportedDatabases(Class<?> ... dbs) {
        OpenJPAEntityManagerFactorySPI tempEMF = emf;
        if (tempEMF == null) {
            tempEMF = createEMF();
        }
        DBDictionary dict = ((JDBCConfiguration)tempEMF.getConfiguration()).getDBDictionaryInstance();
        boolean supportedDB = false;
        for (Class<?> db : dbs) {
            if (dict.getClass().getCanonicalName().equalsIgnoreCase(db.getCanonicalName())) {
                supportedDB = true;
                break;
View Full Code Here


    private DBDictionary dict = null;
    private int lockWaitTime = 2000;

    public void setUp() {
        // Disable tests for any DB that has supportsQueryTimeout==false, like Postgres
        OpenJPAEntityManagerFactorySPI tempEMF = emf;
        if (tempEMF == null) {
            tempEMF = createEMF();
        }
        assertNotNull(tempEMF);
        dict = ((JDBCConfiguration)tempEMF.getConfiguration()).getDBDictionaryInstance();
        assertNotNull(dict);
        if (!dict.supportsQueryTimeout)
            setTestsDisabled(true);
        if (emf == null) {
            closeEMF(tempEMF);
View Full Code Here

    protected ClassMapping [] getMappings() {
        return (ClassMapping [] ) emf.getConfiguration().getMetaDataRepositoryInstance().getMetaDatas();  
    }
   
    protected void setUnsupportedDatabases(Class<?> ... dbs) {
        OpenJPAEntityManagerFactorySPI tempEMF = emf;
        if (tempEMF == null) {
            tempEMF = createEMF();
        }
        DBDictionary dict = ((JDBCConfiguration)tempEMF.getConfiguration()).getDBDictionaryInstance();
        for (Class<?> db : dbs) {
            if (dict.getClass().getCanonicalName().equalsIgnoreCase(db.getCanonicalName())) {
                setTestsDisabled(true);
                break;
            }
View Full Code Here

            closeEMF(tempEMF);
        }
    }
   
    protected void setSupportedDatabases(Class<?> ... dbs) {
        OpenJPAEntityManagerFactorySPI tempEMF = emf;
        if (tempEMF == null) {
            tempEMF = createEMF();
        }
        DBDictionary dict = ((JDBCConfiguration)tempEMF.getConfiguration()).getDBDictionaryInstance();
        boolean supportedDB = false;
        for (Class<?> db : dbs) {
            if (dict.getClass().getCanonicalName().equalsIgnoreCase(db.getCanonicalName())) {
                supportedDB = true;
                break;
View Full Code Here

    final String expectedFailureMsg18 =
        "INSERT INTO Ent1 (pk, name) VALUES (?, ?) [params=(int) 18, (String) name18]";
    String expectedFailureMsgOracle = expectedFailureMsg18;

    public EntityManagerFactory newEmf(String batchLimit) {
        OpenJPAEntityManagerFactorySPI emf =
            createEMF(Ent1.class,
                "openjpa.jdbc.SynchronizeMappings",
                "buildSchema(ForeignKeys=true)",
                "openjpa.jdbc.DBDictionary", batchLimit,
                "openjpa.ConnectionFactoryProperties", "PrintParameters=true",
                CLEAR_TABLES);

        assertNotNull("Unable to create EntityManagerFactory", emf);
        JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
        DBDictionary dict = conf.getDBDictionaryInstance();
        isOracle = dict instanceof OracleDictionary;
        return emf;
    }
View Full Code Here

        Map props = new HashMap(System.getProperties());
        props.put("openjpa.MetaDataFactory", "jpa(Types=" + Person.class.getName() + ")");
        props.put("openjpa.jdbc.QuerySQLCache",
                  "org.apache.openjpa.persistence.compatible.TestQuerySQLCache.BadCacheMap");

        OpenJPAEntityManagerFactorySPI emf1 = null;
        try {
            emf1 = (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
                                                 cast(Persistence.createEntityManagerFactory("test", props));
            //
            // EMF creation must throw an exception because the cache implementation class will not be found
View Full Code Here

        props.put("openjpa.MetaDataFactory", "jpa(Types=" + TblChild.class.getName() + ";"
                                                          + TblGrandChild.class.getName() + ";"
                                                          + TblParent.class.getName() + ")");
        props.put("openjpa.jdbc.QuerySQLCache", "true");

        OpenJPAEntityManagerFactorySPI emf1 = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.
                                             cast(Persistence.createEntityManagerFactory("test", props));
        try {
            EntityManagerImpl em = (EntityManagerImpl)emf1.createEntityManager();
   
            em.getTransaction().begin();
   
            for (int i = 1; i < 3; i++) {
                TblParent p = new TblParent();
View Full Code Here

    /*
     * Verifies compatibility options and spec level are appropriate
     * for a version 2 persistence.xml
     */
    public void testJPA1CompatibilityOptions() {
        OpenJPAEntityManagerFactorySPI emf =
        (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
            createEntityManagerFactory("persistence_1_0",
                "org/apache/openjpa/persistence/compat/" +
                "persistence_1_0.xml");

        try {
            Compatibility compat = emf.getConfiguration().getCompatibilityInstance();
            assertTrue(compat.getFlushBeforeDetach());
            assertTrue(compat.getCopyOnDetach());
            assertTrue(compat.getIgnoreDetachedStateFieldForProxySerialization());
            assertTrue(compat.getPrivatePersistentProperties());
            String vMode = emf.getConfiguration().getValidationMode();
            assertEquals("NONE", vMode);
            Specification spec = emf.getConfiguration().getSpecificationInstance();
            assertEquals("JPA", spec.getName().toUpperCase());
            assertEquals(spec.getVersion(), 1);
        } finally {
            closeEMF(emf);
        }
View Full Code Here

    /*
     * Verifies compatibility options and spec level are appropriate
     * for a version 2 persistence.xml
     */
    public void testJPA2CompatibilityOptions() {
        OpenJPAEntityManagerFactorySPI emf =
        (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
            createEntityManagerFactory("persistence_2_0",
                "org/apache/openjpa/persistence/compat/" +
                "persistence_2_0.xml");

        try {
            Compatibility compat = emf.getConfiguration().getCompatibilityInstance();
            assertFalse(compat.getFlushBeforeDetach());
            assertFalse(compat.getCopyOnDetach());
            assertFalse(compat.getIgnoreDetachedStateFieldForProxySerialization());
            assertFalse(compat.getPrivatePersistentProperties());
            String vMode = emf.getConfiguration().getValidationMode();
            assertEquals("AUTO", vMode);
            Specification spec = emf.getConfiguration().getSpecificationInstance();
            assertEquals("JPA", spec.getName().toUpperCase());
            assertEquals(spec.getVersion(), 2);
        } finally {
            closeEMF(emf);
        }
View Full Code Here

    public void testMappedSuperClass() {
        List<Class<?>> types = new ArrayList<Class<?>>();
        types.add(EntityA.class);
        types.add(EntityB.class);
        types.add(MappedSuper.class);
        OpenJPAEntityManagerFactorySPI emf = createEMF2_0(types);
        EntityManager em = null;
        try {
            em = emf.createEntityManager();
            EntityA a = new EntityA();
            a.setId(1);
            EntityB b = new EntityB();
            b.setId(1);
            a.setEntityB(b);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

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.