public void ejbLoad_If_No_Transaction(ThreadContext callContext, EntityBean bean) throws Exception {
Operation orginalOperation = callContext.getCurrentOperation();
BaseContext.State[] originalAllowedStates = callContext.getCurrentAllowedStates();
if (orginalOperation == Operation.BUSINESS || orginalOperation == Operation.REMOVE) {
TransactionPolicy callerTxPolicy = callContext.getTransactionPolicy();
if (callerTxPolicy != null && callerTxPolicy.isTransactionActive()) {
return;
}
CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
TransactionPolicy txPolicy = deploymentInfo.getTransactionPolicyFactory().createTransactionPolicy(TransactionType.Supports);
try {
// double check we don't have an active transaction
if (!txPolicy.isTransactionActive()) {
callContext.setCurrentOperation(Operation.LOAD);
callContext.setCurrentAllowedStates(EntityContext.getStates());
bean.ejbLoad();
}
} catch (NoSuchEntityException e) {
instanceManager.discardInstance(callContext, bean);
throw new ApplicationException(new NoSuchObjectException("Entity not found: " + callContext.getPrimaryKey())/*.initCause(e)*/);
} catch (Exception e) {
instanceManager.discardInstance(callContext, bean);
throw e;
} finally {
callContext.setCurrentOperation(orginalOperation);
callContext.setCurrentAllowedStates(originalAllowedStates);
txPolicy.commit();
}
}
}