doctrine flush fail === When I register a new account and call findAll() the previous username and password will be turn null but the latest one. ![](![](https://i.imgur.com/UTUux7t.png) ) Then I call findAll() again in the login ,all the username and password will be null but the money. ![](https://i.imgur.com/RmIUcBo.png) var/logs/dev.log ``` [2017-06-13 10:51:59] request.INFO: Matched route "bankRegister". {"route":"bankRegister","route_parameters":{"_controller":"AppBundle\\Controller\\BankController::registerAction","_route":"bankRegister"},"request_uri":"http://127.0.0.1:8000/bank/register","method":"GET"} [] [2017-06-13 10:51:59] security.INFO: Populated the TokenStorage with an anonymous Token. [] [] [2017-06-13 10:51:59] doctrine.DEBUG: "START TRANSACTION" [] [] [2017-06-13 10:51:59] doctrine.DEBUG: INSERT INTO BANK (money) VALUES (?) {"1":"100"} [] [2017-06-13 10:51:59] doctrine.DEBUG: "COMMIT" [] [] [2017-06-13 10:51:59] doctrine.DEBUG: SELECT t0.id AS id_1, t0.money AS money_2 FROM BANK t0 [] [] [2017-06-13 10:52:35] request.INFO: Matched route "bankLogin". {"route":"bankLogin","route_parameters":{"_controller":"AppBundle\\Controller\\BankController::LoginAction","_route":"bankLogin"},"request_uri":"http://127.0.0.1:8000/bank/login","method":"GET"} [] [2017-06-13 10:52:35] security.INFO: Populated the TokenStorage with an anonymous Token. [] [] [2017-06-13 10:52:35] doctrine.DEBUG: SELECT t0.id AS id_1, t0.money AS money_2 FROM BANK t0 [] [] ``` --- BankController.php ```php= <?php namespace AppBundle\Controller; use AppBundle\Entity\Account; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use AppBundle\Form\PostType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; class BankController extends Controller { /** * @Route("bank/register", name = "bankRegister") * @Method("GET") */ public function registerAction() { $account = new Account(); $account->setUsername("eric"); $account->setPassword("777"); $account->setMoney("100"); $em = $this->getDoctrine()->getManager(); $em->persist($account); $em->flush(); $accounts = $em->getRepository('AppBundle:Account'); $account = $accounts->findAll(); $encodersArray = [ new XmlEncoder(), new JsonEncoder() ]; $normalizersArray = [new objectNormalizer()]; $encoders = $encodersArray;; $normalizers = $normalizersArray; $serializer = new Serializer($normalizers, $encoders); $json = $serializer->serialize($account, 'json'); return new Response($json); } /** * @Route("bank/login", name = "bankLogin") * @Method("GET") */ public function LoginAction() { $em = $this->getDoctrine()->getManager(); $accounts = $em->getRepository('AppBundle:Account'); $account = $accounts->findAll(); $encodersArray = [ new XmlEncoder(), new JsonEncoder() ]; $normalizersArray = [new objectNormalizer()]; $encoders = $encodersArray;; $normalizers = $normalizersArray; $serializer = new Serializer($normalizers, $encoders); $json = $serializer->serialize($account, 'json'); return new Response($json); } } ``` --- Account.php ```php= <?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\UserInterface; use \DateTime; /** * @ORM\Entity * @ORM\Table(name="BANK") */ class Account { /** * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /* * @var Username * @ORM\Column(type="string", length=100) */ private $username; /* * @var Password * @ORM\Column(type="string", length=64) */ private $password; /** * @var Money * @ORM\Column(type="integer") */ private $money; /** * Get Id * @return integer */ public function getId() { return $this->id; } /** * Get Username * @return string */ public function getUsername() { return $this->username; } /** * Set Username * @param string $useranme * @return Account */ public function setUsername($username) { $this->username = $username; return $this; } /** * Get Password * @return string */ public function getPassword() { return $this->password; } /** * Set Password * @param string $password * @return Account */ public function setPassword($password) { $this->password = $password; return $this; } /** * Get Money * @return integer */ public function getMoney() { return $this->money; } /** * Set Money * @param integer $money * @return Account */ public function setMoney($money) { $this->money = $money; return $this; } } ``` --- composer.json ```javascript= { ... "require": { "php": ">=5.5.9", "doctrine/doctrine-bundle": "^1.6", "doctrine/doctrine-cache-bundle": "^1.2", "doctrine/orm": "^2.5", "incenteev/composer-parameter-handler": "^2.0", "phpunit/php-code-coverage": "^4.0", "sensio/distribution-bundle": "^5.0", "sensio/framework-extra-bundle": "^3.0.2", "symfony/monolog-bundle": "^3.0.2", "symfony/polyfill-apcu": "^1.0", "symfony/swiftmailer-bundle": "^2.3.10", "symfony/symfony": "3.2.*", "twig/twig": "^1.0||^2.0" }, ... } ```