掲示板

Possible bug with updating user data

7年前 に Csaba Meszaros によって更新されました。

Possible bug with updating user data

Junior Member 投稿: 42 参加年月日: 13/10/10 最新の投稿
Hi!
Liferay 7 GA-3 ,with given code in an action command:

ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
User user = themeDisplay.getUser();
user.setFirstName(ParamUtil.getString(actionRequest, "firstName"));
user.setLastName(ParamUtil.getString(actionRequest, "lastName"));
UserLocalServiceUtil.updateUser(user);

I am getting error:

Application exception overridden by commit exception
org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [com.liferay.portal.model.impl.UserImpl] with identifier [67472]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.liferay.portal.model.impl.UserImpl#67472]

I didn't encounter this in LR 6.2.

How can I change user's details from a portlet? I need a working solution. Thanks!
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: Possible bug with updating user data

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Csaba Meszaros:
Hi!
Liferay 7 GA-3 ,with given code in an action command:

ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
User user = themeDisplay.getUser();
user.setFirstName(ParamUtil.getString(actionRequest, "firstName"));
user.setLastName(ParamUtil.getString(actionRequest, "lastName"));
UserLocalServiceUtil.updateUser(user);

I am getting error:

Application exception overridden by commit exception
org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [com.liferay.portal.model.impl.UserImpl] with identifier [67472]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.liferay.portal.model.impl.UserImpl#67472]

I didn't encounter this in LR 6.2.

How can I change user's details from a portlet? I need a working solution. Thanks!


Did you try to fetch that User first (UserLocalServiceUtil.fetchUser)?
7年前 に Csaba Meszaros によって更新されました。

RE: Possible bug with updating user data

Junior Member 投稿: 42 参加年月日: 13/10/10 最新の投稿
No. I used the wrong way, forgetting the OSGi way.
Now I use:

@Reference
public void setUserLocalService(UserLocalService userLocalService) {
this.userLocalService = userLocalService;
}

public UserLocalService getUserLocalService() {
return userLocalService;
}

private UserLocalService userLocalService;


to obtain userLocalService.
I would like to get a User which I could modify.
I tried also to change profile image, and it does. but only after reload. The image is being updated via ajax, but the returned imagePath is not updated. I am also running into Hibernate exceptions upon update, stating it is a stale data.
Any idea?
7年前 に Csaba Meszaros によって更新されました。

RE: Possible bug with updating user data

Junior Member 投稿: 42 参加年月日: 13/10/10 最新の投稿
All I would like to do is get a User object from ThemeDisplay or get it by userId, modify it and update it, without exceptions. In LR 6.2 it was smooth, now a nightmare.