I think I\'ve tried all code in all posts about authentication with (doctrine) Entity in Symfony 2. And I can`t make it work. When I use in_memory provider all works fine. I
Finally somebody helped me. The issue is that I wasn't using any salt to create the password, and in the getSalt function of the User class I was returning the ID.
The password is generated like this (in the controller):
$factory = $this->container->get('security.encoder_factory');
$encoder = $factory->getEncoder($user);
$pwd = $encoder->encodePassword('your_random_password', $user->getSalt());
$user->setPassword($pwd);