You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Esteve Avilés <ea...@gmail.com> on 2014/11/12 22:17:41 UTC

@Transactional annotiation support

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

Re: @Transactional annotiation support

Posted by Gerhard Petracek <ge...@gmail.com>.
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 <ea...@gmail.com>:

> 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 <
> gerhard.petracek@gmail.com> 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 <gerhard.petracek@gmail.com
> >:
> >
> >> 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 <ea...@gmail.com>:
> >>
> >>> 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 <cm...@gmail.com>
> >>> 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 <ea...@gmail.com>:
> >>> >
> >>> > > 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 <
> >>> > > gerhard.petracek@gmail.com> 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 <ea...@gmail.com>:
> >>> > > >
> >>> > > > > 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
>

Re: @Transactional annotiation support

Posted by Esteve Avilés <ea...@gmail.com>.
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 <
gerhard.petracek@gmail.com> 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 <ge...@gmail.com>:
>
>> 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 <ea...@gmail.com>:
>>
>>> 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 <cm...@gmail.com>
>>> 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 <ea...@gmail.com>:
>>> >
>>> > > 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 <
>>> > > gerhard.petracek@gmail.com> 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 <ea...@gmail.com>:
>>> > > >
>>> > > > > 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

Re: @Transactional annotiation support

Posted by Gerhard Petracek <ge...@gmail.com>.
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 <ge...@gmail.com>:

> 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 <ea...@gmail.com>:
>
>> 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 <cm...@gmail.com>
>> 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 <ea...@gmail.com>:
>> >
>> > > 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 <
>> > > gerhard.petracek@gmail.com> 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 <ea...@gmail.com>:
>> > > >
>> > > > > 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
>>
>
>

Re: @Transactional annotiation support

Posted by Gerhard Petracek <ge...@gmail.com>.
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 <ea...@gmail.com>:

> 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 <cm...@gmail.com>
> 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 <ea...@gmail.com>:
> >
> > > 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 <
> > > gerhard.petracek@gmail.com> 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 <ea...@gmail.com>:
> > > >
> > > > > 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
>

Re: @Transactional annotiation support

Posted by Esteve Avilés <ea...@gmail.com>.
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 <cm...@gmail.com>
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 <ea...@gmail.com>:
>
> > 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 <
> > gerhard.petracek@gmail.com> 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 <ea...@gmail.com>:
> > >
> > > > 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

Re: @Transactional annotiation support

Posted by Charlie Mordant <cm...@gmail.com>.
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 <ea...@gmail.com>:

> 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 <
> gerhard.petracek@gmail.com> 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 <ea...@gmail.com>:
> >
> > > 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

Re: @Transactional annotiation support

Posted by Esteve Avilés <ea...@gmail.com>.
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 <
gerhard.petracek@gmail.com> 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 <ea...@gmail.com>:
>
> > 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

Re: @Transactional annotiation support

Posted by Gerhard Petracek <ge...@gmail.com>.
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 <ea...@gmail.com>:

> 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
>