Note that there are some explanatory texts on larger screens.

plurals
  1. POInsertion happened when update the record
    text
    copied!<p>In my JSF project with Seam3.2.2 integration, Update doesn't work. Instead update the value, it insert the new value in table.</p> <p>Please I need some help here.</p> <p>flow of my project. <br> Pages.xml:</p> <pre><code> &lt;page view-id="/updateUser.xhtml" action="#{userEditAction.setCurrentUser()}"&gt; &lt;navigation&gt; &lt;rule if-outcome="success"&gt; &lt;redirect view-id="/secure/admin/user/updateUser.xhtml"/&gt; &lt;/rule&gt; &lt;/navigation&gt; &lt;begin-conversation join="true"&gt;&lt;/begin-conversation&gt; &lt;/page&gt; </code></pre> <p>UserEditAction.java Bean:</p> <pre><code> @RequestParameter private Integer userId; @Override public String setCurrentUser(){ System.out.println("Selected userid ----- " + userId); currentUser = userService.getUser(userId); return "success"; } </code></pre> <p>userUpdate.xhtml :</p> <pre><code> &lt;h:commandButton value="Update" tabindex="20" action="#{userAction.update}"&gt; &lt;f:param name="userId" value="#{currentUser.userId}" /&gt; &lt;/h:commandButton&gt; </code></pre> <p>userAction.java Bean</p> <pre><code>@Name("userAction") @Stateless @AutoCreate public class UserActionImpl implements UserAction { @Out(value = "currentUser", scope = ScopeType.CONVERSATION) @In(value = "currentUser", scope = ScopeType.CONVERSATION, required = false) private CLRPUser currentUser; @In private UserService userService; @RequestParameter private Integer userId; private static final long serialVersionUID = 8282995226262125676L; public String update() { userService.saveOrUpdate(currentUser); return "success"; } </code></pre> <p>userService.java:</p> <pre><code> public Integer saveOrUpdate(CLRPUser user) { // TODO Validation...check cell phone number.. email id.. // user.setLastUpdatedBy(currentUserId); user.setLastUpdatedBy(loggedInUser.getId()); user.getResidentialAddress().setLastUpdatedBy(loggedInUser.getId()); user.getShippingAddress().setLastUpdatedBy(loggedInUser.getId()); </code></pre> <p>userMapper.java :</p> <pre><code>public class UserMapper { public static UserEntity mapUserEntity(CLRPUser user) { UserEntity userEntity = new UserEntity(); userEntity.setEmailAddress(user.getEmailAddress()); userEntity.setFirstName(user.getFirstName()); userEntity.setLastName(user.getLastName()); userEntity.setHomeNumber(user.getHomeNumber()); userEntity.setOfficeNumber(user.getOfficeNumber()); userEntity.setCellNumber(user.getCellNumber()); AuditInfo auditInfo = new AuditInfo(); auditInfo.setLastUpdatedBy(user.getLastUpdatedBy()); auditInfo.setLastUpdatedTime(user.getLastUpdatedTime()); userEntity.setAuditInfo(auditInfo); userEntity.setType(user.getType()); userEntity.setPreferenceId(user.getPreferenceId()); userEntity.setASPCustomerId(user.getAspCustomerId()); user.getResidentialAddress().setAddressType("R"); user.getShippingAddress().setAddressType("S"); AddressEntity residential = AddressMapper.mapAddressEntity(user .getResidentialAddress()); AddressEntity shipping = AddressMapper.mapAddressEntity(user .getShippingAddress()); List&lt;AddressEntity&gt; addressess = new ArrayList&lt;AddressEntity&gt;(); addressess.add(residential); addressess.add(shipping); userEntity.setAddresses(new HashSet&lt;AddressEntity&gt;(addressess)); /*UserLoginEntity userLogin = UserLoginMapper.mapUserLoginEntity(user.getUserLogin()); List&lt;UserLoginEntity&gt; userLoginn = new ArrayList&lt;UserLoginEntity&gt;(); userLoginn.add(userLogin); userEntity.setUserLogin(new HashSet&lt;UserLoginEntity&gt;(userLoginn));*/ // userEntity.setCardTypeEntity(cardTypeEntity) return userEntity; } </code></pre> <p>JPAUserDAO.java</p> <pre><code> public Integer saveOrUpdate(UserEntity newUser) { entityManager.merge(newUser); return newUser.getUserId(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload