Foren

Liferay transactions

thumbnail
Kevin Gebel, geändert vor 12 Jahren.

Liferay transactions

Junior Member Beiträge: 80 Beitrittsdatum: 27.05.10 Neueste Beiträge
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 :

try
{
[indent]ContactLocalServiceUtil.updateContact(cloneUserLiferay.getContact());[/indent]
[indent]UserLocalServiceUtil.updateUser(cloneUserLiferay);[/indent]
[indent]if (1 == 1) throw new NullPointerException();[/indent]
}
catch (Exception e)
{

}


This code is from a portlet. Data are never rollbacked.
thumbnail
jelmer kuperus, geändert vor 12 Jahren.

RE: Liferay transactions

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
If you use the community issue, it does not include the fix for http://issues.liferay.com/browse/LPS-14475
thumbnail
Kevin Gebel, geändert vor 12 Jahren.

RE: Liferay transactions

Junior Member Beiträge: 80 Beitrittsdatum: 27.05.10 Neueste Beiträge
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 ?
thumbnail
jelmer kuperus, geändert vor 12 Jahren.

RE: Liferay transactions

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
The transactional boundry is defined on the service

So if you do :

ContactLocalServiceUtil.updateContact(cloneUserLiferay.getContact());
UserLocalServiceUtil.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
thumbnail
Kevin Gebel, geändert vor 12 Jahren.

RE: Liferay transactions

Junior Member Beiträge: 80 Beitrittsdatum: 27.05.10 Neueste Beiträge
Ok. Thank you for your expertise Jelmer ;)
Federico Miralles, geändert vor 11 Jahren.

RE: Liferay transactions

New Member Beiträge: 4 Beitrittsdatum: 20.09.12 Neueste Beiträge
Hi Kevin,

You could check:

Liferay Transactional Custom Services Made Easy

Federico Miralles @Rotterdam CS BV