-
2. Re: @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) annotated method does not run in a separate transaction
janvandeklok May 12, 2014 6:04 AM (in response to jaikiran)jaikiran pai, thanks for your response. I looked into the link you send me.
this is our interaction class:
@Stateless
public class CaseManager
{
@Inject
@DAOType(Type.JCR)
private CaseDAOInf caseDAO = null;
.....
...
private void createCase(CaseResourcePath parentPath, Case caseObj)
{
Preconditions.checkNotNull(caseObj, "No caseObj was supplied");
Preconditions.checkNotNull(parentPath, "No case resource path was supplied to store the caseObj");
// Generate unique casenumber
caseObj.setCaseNumber(caseDAO.generateCaseNumber(parentPath));
// first get the case definition that the provided caseObj references
CaseDefinition caseDef = caseDefMngr.getPublishedCaseDefinitionByPath(caseObj.getCaseDefinitionPath());
caseObj.setCaseDefinition(caseDef);
...
...
}
---------------------------------------------------------------------
and this is the CaseDao implementation
@DAOType(Type.JCR)
@RequestScoped
public class CaseDAO extends AbstractDAO implements CaseDAOInf
{
...
...
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public synchronized long generateCaseNumber(final CaseResourcePath parentPath)
{
// // we expect a new transaction here
long number = 100000000;
try
{
session.refresh(true);
Node parentNode = session.getNode(parentPath.absolutePath);
if (parentNode.hasProperty(PROP_KEY_LAST_ISSUED_ID))
{
javax.jcr.Property lastIssuedId = parentNode.getProperty(PROP_KEY_LAST_ISSUED_ID);
number = lastIssuedId.getLong() + 1;
}
parentNode.setProperty(PROP_KEY_LAST_ISSUED_ID, number);
session.save();
return number; // we expect the transaction to commit here
}.
catch (RepositoryException e)
{
logger.error("Could not issue a new casenumber on path {}", parentPath.absolutePath);
throw Throwables.propagate(e);
}
}
...
...
}
-----------------------------------------
So why is this not working? It is calling the method on the business object of the bean or not??
-
3. Re: @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) annotated method does not run in a separate transaction
puneetsrivastava May 13, 2014 2:47 AM (in response to janvandeklok)I am facing the similar issue. Using EAP 5.2.0.