use of org.datanucleus.Transaction in project datanucleus-api-jdo by datanucleus.
the class PersistentNontransactional method transitionWriteField.
/**
* Method to transition to write-field state.
* @param op ObjectProvider.
* @return new LifeCycle state.
*/
public LifeCycleState transitionWriteField(ObjectProvider op) {
Transaction tx = op.getExecutionContext().getTransaction();
if (!tx.isActive() && !tx.getNontransactionalWrite()) {
throw new TransactionNotWritableException(Localiser.msg("027001"), op.getInternalObjectId());
}
if (tx.isActive()) {
// Save the fields for rollback.
op.saveFields();
return changeState(op, P_DIRTY);
}
// Save the fields for rollback.
op.saveFields();
return changeState(op, P_NONTRANS_DIRTY);
}
use of org.datanucleus.Transaction in project datanucleus-api-jdo by datanucleus.
the class PersistentNontransactional method transitionReadField.
/**
* Method to transition to read-field state.
* @param op ObjectProvider.
* @param isLoaded if the field was previously loaded.
* @return new LifeCycle state.
*/
public LifeCycleState transitionReadField(ObjectProvider op, boolean isLoaded) {
Transaction tx = op.getExecutionContext().getTransaction();
if (!tx.isActive() && !tx.getNontransactionalRead()) {
throw new TransactionNotReadableException(Localiser.msg("027002"), op.getInternalObjectId());
}
if (tx.isActive() && !tx.getOptimistic()) {
// Save the fields for rollback.
op.saveFields();
op.refreshLoadedFields();
return changeState(op, P_CLEAN);
}
return this;
}
use of org.datanucleus.Transaction in project datanucleus-api-jdo by datanucleus.
the class PersistentDirty method transitionRefresh.
/**
* Method to transition to refresh state.
* @param op ObjectProvider.
* @return new LifeCycle state.
*/
public LifeCycleState transitionRefresh(ObjectProvider op) {
op.clearSavedFields();
// Refresh the FetchPlan fields and unload all others
op.refreshFieldsInFetchPlan();
op.unloadNonFetchPlanFields();
Transaction tx = op.getExecutionContext().getTransaction();
if (tx.isActive() && !tx.getOptimistic()) {
return changeState(op, P_CLEAN);
}
return changeState(op, P_NONTRANS);
}
Aggregations