Beginner |
|
Joined: Thu Sep 01, 2005 7:43 am Posts: 31 Location: León (Spain)
|
Either user an HQL update like:
"update User u set u.userName = theUserName where u.userId = theUserId"
Or use an HQL query to retrieve the row by USER_ID, and then update the object. You should ensure that USER_IDs are unique:
Query q = session.createQuery("from User u where u.userId = theId");
User theUser = (User)q.uniqueResult();
theUser.setUserName(theName);
session.update(theUser);
If not unique, the only way I know is to programatically select the row from the list of possible results:
List users = q.list();
Iterator it = users.iterator();
while (it.hasNext()) {
// do whatever you can
}
_________________ Please rate...
Expert on Hibernate errors... I've had them all... :P
|
|