Save an existing User Exception

I’m trying to reset the password of an existing user to a random value.

User u =identityService.createUserQuery()
    	.userId(userId).singleResult();
u.setPassword(userId + (Math.random() * 100000000));
identityService.saveUser(u);

The saveUser generated the following exception:
org.camunda.bpm.engine.ProcessEngineException: ENGINE-03003 Inserting an entity with Id ‘user106’ and type ‘class org.camunda.bpm.engine.impl.persistence.entity.UserEntity’ which is already marked with state ‘PERSISTENT’.

I read the rest code for this operation in git, and it seems exactly the same: the user is retrieved with createUserQuery and saved after setting the property using saveUser.

Nevermind.

I created the user with rev_ = 0. This will generate any sort of error for updates. The rev_ must be set to 1.