Search in sources :

Example 1 with JDOException

use of com.sun.jdo.api.persistence.support.JDOException in project Payara by payara.

the class RuntimeVersion method loadProperties.

/**
 * Load properties file
 */
public static void loadProperties(String fileName) {
    try {
        InputStream in = RuntimeVersion.class.getResourceAsStream(fileName);
        if (in == null)
            throw new FileNotFoundException(fileName);
        _properties.load(in);
        in.close();
    } catch (java.io.IOException e) {
        throw new JDOException(null, e);
    }
}
Also used : InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) JDOException(com.sun.jdo.api.persistence.support.JDOException)

Example 2 with JDOException

use of com.sun.jdo.api.persistence.support.JDOException in project Payara by payara.

the class TransactionImpl method rollback.

/**
 * Rollback the transaction represented by this transaction object.
 */
public void rollback() {
    persistenceManager.acquireExclusiveLock();
    try {
        if (txType == CMT || txType == BMT_UT) {
            // Error - should not be called
            throw new JDOUserException(I18NHelper.getMessage(messages, "transaction.transactionimpl.mgd", // NOI18N
            "rollback"));
        }
        this.setTrace();
        if (this.tracing)
            // NOI18N
            this.traceCall("rollback");
        if ((this.status != Status.STATUS_ACTIVE) && (this.status != Status.STATUS_MARKED_ROLLBACK)) {
            throw new JDOUserException(I18NHelper.getMessage(messages, // NOI18N
            "transaction.transactionimpl.commit_rollback.notactive", // NOI18N
            "rollback", this.statusString(this.status)));
        }
        this.setStatus(Status.STATUS_ROLLING_BACK);
        this.internalRollback();
        this.closeConnection();
        if (txType == BMT_JDO) {
            // Send request to the container:
            try {
                EJBHelper.getLocalTransactionManager().rollback();
            } catch (Exception e) {
                // NOI18N
                throw new JDOException("", e);
            }
        } else {
            // NON_MGD
            // This has effect of rolling back changes also
            // which would not happen in case of BMT_JDO
            // Is this the desired behavior ?
            // TransactionImpl.notifyAfterCompletion()
            // PersistenceManagerImp.afterCompletion()
            // SQLStateManager.rollback()
            this.notifyAfterCompletion();
        }
    } finally {
        persistenceManager.releaseExclusiveLock();
    }
}
Also used : JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException) JDOException(com.sun.jdo.api.persistence.support.JDOException) JDOUnsupportedOptionException(com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException) JDODataStoreException(com.sun.jdo.api.persistence.support.JDODataStoreException) JDOFatalInternalException(com.sun.jdo.api.persistence.support.JDOFatalInternalException) JDOException(com.sun.jdo.api.persistence.support.JDOException)

Example 3 with JDOException

use of com.sun.jdo.api.persistence.support.JDOException in project Payara by payara.

the class QueryImpl method doExecute.

/**
 * Internal method called by execute, executeWithArray, executeWithMap.
 * - calls the code generation of the query compiler
 * - flushes updates
 * - executes the RetrieveDesc returned by the code generation
 * - resets the compiler
 */
private Object doExecute(ParameterTable params) {
    Object result = null;
    RetrieveDesc rd = null;
    try {
        // We need to make sure that no parallel thread closes the pm =>
        // try to get a shared lock for the pm. Today, the pm impl does
        // not allow to promote a shared lock into a exclusive lock. Thus
        // we need to get an exclusive lock here. Otherwise pm.internalFlush
        // runs into a deadlock, because it tries to get a exclusive lock.
        // This code need to be changed to get a ahared lock as soon as
        // The next line might result in a NPE, if pm is closed or if the
        // query instance was deserialized. Please note, I cannot check the
        // pm and then get the lock, because the pm might be closed in
        // parallel. Then subsequent uses of pm in doexecute would fail.
        pm.acquireExclusiveLock();
    } catch (NullPointerException npe) {
        // NPE means pm is closed or query instance was serialized.
        String key = (createdBySerialization ? // NOI18N
        "query.queryimpl.doexecute.notboundtopm" : // NOI18N
        "query.queryimpl.doexecute.pmclosed");
        JDOException ex = new JDOQueryException(I18NHelper.getMessage(messages, key));
        // NOI18N
        logger.throwing("query.QueryImpl", "compile", ex);
        throw ex;
    }
    try {
        checkCandidates();
        // call the code generation
        rd = jqlc.codeGen(pm, params);
        // flush changes (inserts, updates, deletes) to the datastore
        flush();
        if (logger.isLoggable(Logger.FINER))
            // NOI18N
            logger.finer("LOG_ExecuteQuery", this, params.getValues());
        // Note, the RetrieveDesc returned by the code generation is null
        // in the case of a query having a false filter =>
        // do not go to the datastore, but return an emtpy collection
        result = (rd != null) ? pm.retrieve(rd, params.getValueFetcher()) : new ArrayList();
    } finally {
        // Note, the following stmt needs to be replaced by
        // pm.releaseSharedLock, as soon as the pm supports promoting a
        // shared lock into an exclusive lock.
        pm.releaseExclusiveLock();
    }
    return result;
}
Also used : RetrieveDesc(com.sun.jdo.spi.persistence.support.sqlstore.RetrieveDesc) ArrayList(java.util.ArrayList) JDOException(com.sun.jdo.api.persistence.support.JDOException) JDOQueryException(com.sun.jdo.api.persistence.support.JDOQueryException)

Example 4 with JDOException

use of com.sun.jdo.api.persistence.support.JDOException in project Payara by payara.

the class TransactionImpl method begin.

// 
// ----- Methods from javax.transaction.Transaction interface ------
// 
/**
 * Begin a transaction.
 */
public void begin() {
    persistenceManager.acquireExclusiveLock();
    try {
        // Check and set status...
        beginInternal();
        // BMT with JDO Transaction
        if (EJBHelper.isManaged()) {
            txType = BMT_JDO;
            try {
                TransactionManager tm = EJBHelper.getLocalTransactionManager();
                tm.begin();
                jta = tm.getTransaction();
                EJBHelper.registerSynchronization(jta, this);
                pmFactory.registerPersistenceManager(persistenceManager, jta);
            } catch (JDOException e) {
                // re-throw it.
                throw e;
            } catch (Exception e) {
                throw new JDOFatalInternalException(I18NHelper.getMessage(messages, "transaction.transactionimpl.begin.failedlocaltx"), // NOI18N
                e);
            }
        } else {
            txType = NON_MGD;
        }
    } finally {
        persistenceManager.releaseExclusiveLock();
    }
}
Also used : JDOFatalInternalException(com.sun.jdo.api.persistence.support.JDOFatalInternalException) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException) JDOException(com.sun.jdo.api.persistence.support.JDOException) JDOUnsupportedOptionException(com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException) JDODataStoreException(com.sun.jdo.api.persistence.support.JDODataStoreException) JDOFatalInternalException(com.sun.jdo.api.persistence.support.JDOFatalInternalException) JDOException(com.sun.jdo.api.persistence.support.JDOException)

Aggregations

JDOException (com.sun.jdo.api.persistence.support.JDOException)4 JDODataStoreException (com.sun.jdo.api.persistence.support.JDODataStoreException)2 JDOFatalInternalException (com.sun.jdo.api.persistence.support.JDOFatalInternalException)2 JDOUnsupportedOptionException (com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException)2 JDOUserException (com.sun.jdo.api.persistence.support.JDOUserException)2 JDOQueryException (com.sun.jdo.api.persistence.support.JDOQueryException)1 RetrieveDesc (com.sun.jdo.spi.persistence.support.sqlstore.RetrieveDesc)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1