Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Kevin Gebel
Liferay transactions
18 novembre 2011 08:24
Réponse

Kevin Gebel

Rang: Junior Member

Publications: 80

Date d'inscription: 27 mai 2010

Publications Récentes

Hello

I have been turning around for days so, please, I really need help !
I try to rollback when exception occurs (create a transaction) when I call the following services :

 1try
 2{
 3[indent]ContactLocalServiceUtil.updateContact(cloneUserLiferay.getContact());[/indent]
 4[indent]UserLocalServiceUtil.updateUser(cloneUserLiferay);[/indent]
 5[indent]if (1 == 1) throw new NullPointerException();[/indent]
 6}
 7catch (Exception e)
 8{
 9
10}


This code is from a portlet. Data are never rollbacked.
Jelmer Kuperus
RE: Liferay transactions
18 novembre 2011 16:08
Réponse

Jelmer Kuperus

Rang: Liferay Legend

Publications: 1192

Date d'inscription: 10 mars 2010

Publications Récentes

If you use the community issue, it does not include the fix for http://issues.liferay.com/browse/LPS-14475
Kevin Gebel
RE: Liferay transactions
21 novembre 2011 00:57
Réponse

Kevin Gebel

Rang: Junior Member

Publications: 80

Date d'inscription: 27 mai 2010

Publications Récentes

Thank you.

In a normal way, how should I manage a transaction here ?
Will the fix be available in 6.1 version of the portal ?
Jelmer Kuperus
RE: Liferay transactions
21 novembre 2011 01:29
Réponse

Jelmer Kuperus

Rang: Liferay Legend

Publications: 1192

Date d'inscription: 10 mars 2010

Publications Récentes

The transactional boundry is defined on the service

So if you do :

1ContactLocalServiceUtil.updateContact(cloneUserLiferay.getContact());
2UserLocalServiceUtil.updateUser(cloneUserLiferay);


Those will be two transactions. To make them run within a single transaction you would have to use service builder to generate an "empty" service on which you define a method that wraps the two service calls

And yes, that issue should be solved in liferay 6.1
Kevin Gebel
RE: Liferay transactions
21 novembre 2011 01:38
Réponse

Kevin Gebel

Rang: Junior Member

Publications: 80

Date d'inscription: 27 mai 2010

Publications Récentes

Ok. Thank you for your expertise Jelmer ;)
Federico Miralles
RE: Liferay transactions
18 mars 2013 06:28
Réponse

Federico Miralles

Rang: New Member

Publications: 7

Date d'inscription: 20 septembre 2012

Publications Récentes

Hi Kevin,

You could check:

Liferay Transactional Custom Services Made Easy

Federico Miralles @Rotterdam CS BV