Examples of OpenJPAEntityManagerFactorySPI


Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

    }

    private synchronized void registerListener(EntityManager entityManager) {
        if (entityManager instanceof OpenJPAEntityManagerSPI) {
            OpenJPAEntityManagerSPI openjpaEM = (OpenJPAEntityManagerSPI) entityManager;
            OpenJPAEntityManagerFactorySPI openjpaEMF = (OpenJPAEntityManagerFactorySPI) openjpaEM.getEntityManagerFactory();

            if (entityManagerListener == null) {
                entityManagerListener = new OpenJPALifecycleListener();
            }
            openjpaEMF.addLifecycleListener(entityManagerListener, (Class[])null);
            return;
        }

        Object delegate = entityManager.getDelegate();
        if (delegate != entityManager && delegate instanceof EntityManager) {
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

    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

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

     * not create them automatically.
     * Oracle, MySQL, MSSQL and Sybase also don't create schemas automatically but
     * we give up as they treat schemas in special ways.
     */
    private void createSchemas() {
        OpenJPAEntityManagerFactorySPI tempEmf = createEMF();
        DBDictionary dict = ((JDBCConfiguration) tempEmf.getConfiguration()).getDBDictionaryInstance();
       
        if (!(dict instanceof PostgresDictionary || dict instanceof H2Dictionary ||
            dict instanceof SolidDBDictionary || dict instanceof HSQLDictionary)) {
            closeEMF(tempEmf);
            return;
        }
       
        OpenJPAEntityManagerSPI em = tempEmf.createEntityManager();
        String[] schemas =
            { "SCHEMA1", "SCHEMA2", "SCHEMA3", "SCHEMA3G", "SCHEMA4G" };
        for (String schema : schemas) {
            try {
                em.getTransaction().begin();
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

     *            list of persistent types used in testing and/or configuration values in the form
     *            key,value,key,value...
     */
    protected OpenJPAEntityManagerFactorySPI createNamedEMF(final String pu, Object... props) {
        Map<String, Object> map = getPropertiesMap(props);
        OpenJPAEntityManagerFactorySPI oemf = null;
        Map<Object, Object> config = new HashMap<Object, Object>(System.getProperties());
        config.putAll(map);
        oemf = (OpenJPAEntityManagerFactorySPI) Persistence.createEntityManagerFactory(pu, config);
        if (oemf == null) {
            throw new NullPointerException("Expected an entity manager factory " + "for the persistence unit named: \""
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

     *            list of persistent types used in testing and/or configuration values in the form
     *            key,value,key,value...
     */
    protected OpenJPAEntityManagerFactorySPI createNamedOpenJPAEMF(final String pu,
            String res, Map<String,Object> props) {
        OpenJPAEntityManagerFactorySPI oemf = null;
        Map<Object, Object> config = new HashMap<Object, Object>(System.getProperties());
        if (props != null)
            config.putAll(props);
        oemf = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory(pu, res, props);
        if (oemf == null) {
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

     */
    public void verifyRefresh(boolean useDataCache, LockModeType lock,
            boolean makeDirtyBeforeRefresh, boolean refreshFromDataCache,
            String expected) {
        OpenJPAEntityManagerFactorySPI emf = (useDataCache)
            ? emfWithDataCache : emfWithoutDataCache;
        emf.getConfiguration().setRefreshFromDataCache(refreshFromDataCache);
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
       
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
        em.persist(pc);
        em.getTransaction().commit();
       
        Object oid = pc.getId();
        StoreCache dataCache = emf.getStoreCache();
        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
       
        // Modify the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

     * @param useDataCache
     * @param lock
     */
    public void verifyDeleteDetectionOnRefresh(boolean useDataCache,
            boolean dirty, LockModeType lock, Class<?> expectedExceptionType) {
        OpenJPAEntityManagerFactorySPI emf = (useDataCache)
            ? emfWithDataCache : emfWithoutDataCache;
           
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
       
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
        em.persist(pc);
        em.getTransaction().commit();
       
        Object oid = pc.getId();
        StoreCache dataCache = emf.getStoreCache();
        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
       
        // delete the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

            Contact.class, EquityAnnuity.class, FixedAnnuity.class, Payor.class, Payout.class, Person.class,
            Rider.class);
    }

    public void testSerialization() throws Exception {
        OpenJPAEntityManagerFactorySPI emf =
            (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory("Annuity1Compat",
                "org/apache/openjpa/persistence/proxy/persistence1.xml");
        assertNotNull(emf);

        EntityManager em = emf.createEntityManager();
        try {
            em.getTransaction().begin();
            Annuity ann = createAnnuity(em);

            // Make sure that we can detach an Entity via serialization that is currently associated
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

        overridePropertyOnEM("javax.persistence.nonJtaDataSource", jndiNames[0]);
    }

    public void overridePropertyOnEM(String name, String value) {
        // use the default JndiName for the base EntityManagerFactory
        OpenJPAEntityManagerFactorySPI emf1 = (OpenJPAEntityManagerFactorySPI)getEmf(name, defaultJndiName);
        assertNotNull(emf1);
        try {
            OpenJPAEntityManagerSPI em = emf1.createEntityManager();
            assertNotNull(em);

            EntityManager em1 = getEm(emf1, name, value);
            assertNotNull(em1);
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

        overridePropertyOnEM("javax.persistence.jtaDataSource", jndiNames[0]);
    }

    public void overridePropertyOnEM(String name, String value) {
        // use the default JndiName for the base EntityManagerFactory
        OpenJPAEntityManagerFactorySPI emf1 = (OpenJPAEntityManagerFactorySPI)getEmf(name, defaultJndiName);
        assertNotNull(emf1);
        try {
            OpenJPAEntityManagerSPI em = emf1.createEntityManager();
            assertNotNull(em);

            EntityManager em1 = getEm(emf1, name, value);
            assertNotNull(em1);
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.