deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Esteve Avilés <eavil...@gmail.com>
Subject @Transactional annotiation support
Date Wed, 12 Nov 2014 21:17:41 GMT
Hi all,

I am using Deltaspike 1.0.3 in a JBoss EAP 6.3 server. We want to use
@Transactional annotation to delimiter a transactions. We use JTA and we
have set the beans alternative and created extended entity manager.

After setting @Transactional as follows (we first call
createAllValsForAPromocioValDescompte):
/**
 * Facade method for createAllValsForAPromocioValDescompte.
 * It first gets the PromocioValDescompte by its Id and then calls
createAllValsForAPromocioValDescompte
 * @param promocioValDescompteId
 * @throws BusinessException
 */
public void createAllValsForAPromocioValDescompte(Long
promocioValDescompteId) throws BusinessException {
PromocioValDescompte promocio = retrieveById(promocioValDescompteId);
if(promocio != null) {
updateStatusToInProgress(promocio);
this.createAllValsForAPromocioValDescompte(promocio);
} else {
log.error("PromocioValDescompte no trobat amb Id {} per proces creacio
vals", promocioValDescompteId);
}
}
 @Transactional(readOnly = false)
public void updateStatusToInProgress(PromocioValDescompte
promocioValDescompte) throws BusinessException {
promocioValDescompte.setEstatProcesGeneracio(EstatPromocioValDescompte.EN_EXECUCIO);
promocioValDescompteRepository.saveAndFlush(promocioValDescompte);
}
 /**
 * Generates all vouchers that will be contained in the
EmissioVoucherPredefinit
 * @param promocioValDescompte
 * @param emissorVoucher
 * @param tipusVoucher
 * @throws BusinessException
 */
@Transactional
public void createAllValsForAPromocioValDescompte(PromocioValDescompte
promocioValDescompte) throws BusinessException {

log.info("Inici creacio de {} vals per a l'emissio {} i Id {}",
promocioValDescompte.getQuantitatDemanada(), promocioValDescompte.getNom(),
promocioValDescompte.getId());
promocioValDescompte.setQuantitatGenerada(0);
.....

We see all methods executed in a unique transaction, and database is only
updated at the end.

Do we need to set something else? Before that, in a JEE5 env, we were
using @Transactional(TransactionPropagationType.REQUIRED)
and @Transactional(TransactionPropagationType.NEVER) to achieve the same
objective.

Can anyone help us?

Thanks in advance.

Regards,

-- 
Esteve Avilés

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message