Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why

Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Kevin Gebel
Liferay transactions
November 18, 2011 8:24 AM
Answer

Kevin Gebel

Rank: Junior Member

Posts: 80

Join Date: May 27, 2010

Recent Posts

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
November 18, 2011 4:08 PM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

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
November 21, 2011 12:57 AM
Answer

Kevin Gebel

Rank: Junior Member

Posts: 80

Join Date: May 27, 2010

Recent Posts

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
November 21, 2011 1:29 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

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
November 21, 2011 1:38 AM
Answer

Kevin Gebel

Rank: Junior Member

Posts: 80

Join Date: May 27, 2010

Recent Posts

Ok. Thank you for your expertise Jelmer ;)
Federico Miralles
RE: Liferay transactions
March 18, 2013 6:28 AM
Answer

Federico Miralles

Rank: New Member

Posts: 7

Join Date: September 20, 2012

Recent Posts

Hi Kevin,

You could check:

Liferay Transactional Custom Services Made Easy

Federico Miralles @Rotterdam CS BV