Symfony 2 Get original data of entity from entity manager

You can access the original data by getting doctrine's Unit of Work.As from docs

You can get direct access to the Unit of Work by calling EntityManager#getUnitOfWork(). This will return the UnitOfWork instance the EntityManager is currently using.An array containing the original data of entity

Grab the password from Unit of Work and use in your setter method

public function preUpdate($object)
{

    $DM = $this->getConfigurationPool()->getContainer()->get('Doctrine')->getManager();
    $uow = $DM->getUnitOfWork();
    $OriginalEntityData = $uow->getOriginalEntityData( $object );
    $Password = $object->getUserPassword();
    if (!empty($Password)) { /* i check here if user has enter password then update it goes well*/
        $salt = md5(time());
        $encoderservice = $this->getConfigurationPool()->getContainer()->get('security.encoder_factory');
        $User = new User();
        $encoder = $encoderservice->getEncoder($User);
        $encoded_pass = $encoder->encodePassword($Password, $salt);
        $object->setUserSalt($salt)->setUserPassword($encoded_pass);
    } else { /* here i try to set the old password if user not enters the new password but fails */
        $object->setUserPassword($OriginalEntityData['Password']);/* your property name for password field */
    }
}

Hope it works fine

Direct access to a Unit of Work