hi esteve, now you can extend e.g. BeanManagedUserTransactionStrategy and add the logic you need by overriding the new methods (see DELTASPIKE-780).
regards, gerhard http://www.irian.at Your JavaEE powerhouse - JavaEE Consulting, Development and Courses in English and German Professional Support for Apache MyFaces, DeltaSpike and OpenWebBeans 2014-11-14 19:45 GMT+01:00 Esteve Avilés <[email protected]>: > Ok, > > Thank you all for your time and support. Really appreciate that. > > Regards, > > Esteve > > On Fri, Nov 14, 2014 at 6:08 PM, Gerhard Petracek < > [email protected]> wrote: > > > short addition: > > > > we could provide e.g. #beforeBegin and #afterProceed -> with that you > just > > need to provide a TransactionStrategy which > > extends BeanManagedUserTransactionStrategy. > > -> resolve the TransactionManager and use the std. api to suspend/resume > > the transaction based on meta-data provided by the InvocationContext. > > > > regards, > > gerhard > > > > http://www.irian.at > > > > Your JavaEE powerhouse - > > JavaEE Consulting, Development and > > Courses in English and German > > > > Professional Support for Apache > > MyFaces, DeltaSpike and OpenWebBeans > > > > 2014-11-13 21:45 GMT+01:00 Gerhard Petracek <[email protected] > >: > > > >> hi esteve, > >> > >> suspending a transaction is just supported by jta. since > >> @org.apache.deltaspike.jpa.api.transaction.Transactional shouldn't cover > >> 1:1 what ejbs provide already, it's just not supported. -> if you need > it, > >> you can handle the suspend/resume manually (or via an own > >> TransactionStrategy based on BeanManagedUserTransactionStrategy) or you > >> just use ejbs instead. > >> > >> regards, > >> gerhard > >> > >> http://www.irian.at > >> > >> Your JavaEE powerhouse - > >> JavaEE Consulting, Development and > >> Courses in English and German > >> > >> Professional Support for Apache > >> MyFaces, DeltaSpike and OpenWebBeans > >> > >> 2014-11-13 20:41 GMT+01:00 Esteve Avilés <[email protected]>: > >> > >>> Charlie, > >>> > >>> What I want to achieve is the following over the same EM: > >>> > >>> 1. Start Transaction1 on method_1 > >>> 2. Start Transaction2 on method_1.method_2 > >>> 3. Commit Transaction2 on method_1.method_2 > >>> 4. Commit Transaction1 on method_1 > >>> > >>> What do I have to do? Thanks in advance. I find the use case trivial > but > >>> very hard to achieve. > >>> > >>> Regards, > >>> > >>> Esteve > >>> > >>> On Thu, Nov 13, 2014 at 5:32 PM, Charlie Mordant <[email protected]> > >>> wrote: > >>> > >>> > Hi Esteve, > >>> > > >>> > Your question is not easy to understand, as commiting the transaction > >>> at > >>> > the end of all @Transactional annotated methods is what your code is > >>> > expected to do. > >>> > > >>> > Here's how this @Transactional annotation works: > >>> > > >>> > * To start a new transaction, annotate a method with @Transactional: > >>> the > >>> > transaction will start at the call. > >>> > * To continue the transaction between multiple method calls, annotate > >>> all > >>> > the methods you want to be part of the transaction with > @Transactional. > >>> > * To commit a transaction, make a call on a method which is not > >>> annotated. > >>> > * To rollback, throw an exception (that is not catched in the chain > if > >>> > think). > >>> > > >>> > Regards, > >>> > Charlie > >>> > > >>> > > >>> > 2014-11-13 16:17 GMT+01:00 Esteve Avilés <[email protected]>: > >>> > > >>> > > Gerhard, > >>> > > > >>> > > Thanks for the reply. I don't understand from your reply and > >>> > documentation > >>> > > if I would be able to achieve what I told you in this particular > >>> > > environment. > >>> > > > >>> > > Thanks in advance. > >>> > > > >>> > > Esteve > >>> > > > >>> > > On Thu, Nov 13, 2014 at 9:26 AM, Gerhard Petracek < > >>> > > [email protected]> wrote: > >>> > > > >>> > > > hi esteve, > >>> > > > > >>> > > > if you have one persistence-unit, the interceptor-logic executed > >>> for > >>> > the > >>> > > > outermost transactional method will #begin and finally > >>> > #commit/#rollback > >>> > > > the transaction for the UserTransaction provided by the container > >>> (see > >>> > > > BeanManagedUserTransactionStrategy). > >>> > > > > >>> > > > regards, > >>> > > > gerhard > >>> > > > > >>> > > > http://www.irian.at > >>> > > > > >>> > > > Your JavaEE powerhouse - > >>> > > > JavaEE Consulting, Development and > >>> > > > Courses in English and German > >>> > > > > >>> > > > Professional Support for Apache > >>> > > > MyFaces, DeltaSpike and OpenWebBeans > >>> > > > > >>> > > > > >>> > > > > >>> > > > 2014-11-12 22:17 GMT+01:00 Esteve Avilés <[email protected]>: > >>> > > > > >>> > > > > 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 > >>> > > > > > >>> > > > > >>> > > > >>> > > > >>> > > > >>> > > -- > >>> > > Esteve Avilés > >>> > > > >>> > > >>> > > >>> > > >>> > -- > >>> > Charlie Mordant > >>> > > >>> > Full OSGI/EE stack made with Karaf: > >>> > https://github.com/OsgiliathEnterprise/net.osgiliath.parent > >>> > > >>> > >>> > >>> > >>> -- > >>> Esteve Avilés > >>> > >> > >> > > > > > -- > Esteve Avilés >
