title: Hibernate: saveorupdate() not updating the object
body: <p>I am using spring to maintain the transaction in my application.
  I want to save new and update the existing userdetails in DB.But I am not able to update my changes to database. See my below code and tell what I am doing wrong in my code?  </p>
  
  <pre><code> Session session = getSessionFactory().getCurrentSession();
              UserDetails userDetails = (UserDetails) session.get(
                      UserDetails.class, new Integer(userId));
  
              if (userDetails!= null) {           
                  userDetails.setUserName(name);
                  userDetails.setUserDesc(desc);
              } else {
                  userDetails= new UserAuthDetails();
                  userDetails.setId(userId);
                  userDetails.setUserName(name);
                  userDetails.setUserDesc(desc);
                  userDetails.setCreatedDt(new Date());
              }
  
              session.saveOrUpdate(userDetails);
  </code></pre>
  
  <p>Can anyone help to update the existing userdetail object?</p>