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);
}
}
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();
}
}
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;
}
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();
}
}
Aggregations