Witam,

Dzisiaj napotkałem się na dziwny błąd. Mianowicie mam encje: User oraz AbstractUserAccount
Encja User:
  1. /**
  2.  * Class User
  3.  * @package Crmatic\Bundle\SecurityBundle\Entity
  4.  *
  5.  * @ORM\Entity(repositoryClass="Crmatic\Bundle\SecurityBundle\Repository\UserRepository")
  6.  * @ORM\Table(name="users")
  7.  */
  8. class User extends AbstractEntity implements UserInterface {
  9. //...
  10. /**
  11.   * @ORM\OneToMany(targetEntity="Crmatic\Bundle\SecurityBundle\Entity\AbstractUserAccount", mappedBy="user")
  12.   *
  13.   * @var AbstractUserAccount[]
  14.   */
  15. protected $userAccounts;
  16. //...
  17. }

Encja AbstractUserAccount:

  1.  
  2. /**
  3.  * Class AbstractUserAccount
  4.  * @package Crmatic\Bundle\SecurityBundle\Entity
  5.  *
  6.  * @ORM\Entity(repositoryClass="Crmatic\Bundle\SecurityBundle\Repository\UserAccountRepository")
  7.  * @ORM\Table(name="users_accounts",
  8.  * uniqueConstraints={@ORM\UniqueConstraint(
  9.  * name="unique_user_accounts",
  10.  * columns={"account_id", "user_id", "role_id"}
  11.  * )}
  12.  * )
  13.  * @ORM\InheritanceType("JOINED")
  14.  * @ORM\DiscriminatorColumn(name="discr", type="string")
  15.  * @ORM\DiscriminatorMap({
  16.  * "client" = "Crmatic\Bundle\SecurityBundle\Entity\UserAccount\ClientAccount",
  17.  * "owner" = "Crmatic\Bundle\SecurityBundle\Entity\UserAccount\OwnerAccount"
  18.  * })
  19.  */
  20. class AbstractUserAccount {
  21. /**
  22.   * @ORM\ManyToOne(targetEntity="Crmatic\Bundle\SecurityBundle\Entity\User", inversedBy="userAccounts")
  23.   * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  24.   *
  25.   * @var User
  26.   */
  27. protected $user;
  28.  
  29. /**
  30.   * @ORM\ManyToOne(targetEntity="Crmatic\Bundle\SecurityBundle\Entity\Account")
  31.   * @ORM\JoinColumn(name="account_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  32.   *
  33.   * @var Account
  34.   */
  35. protected $account;
  36. }

W bazie mam 2 rekordy:
| id | user_id | account_id | discr
| 4 | 1 | 1 | owner
| 5 | 1 | 1 | client

Użytkownik po zalogowaniu ma możliwość wybrania konta. Po zalogowaniu użytkownik jest zapisywany do sesji. Gdy przechodzę na stronę z wyborem konta nie wiem czemu dla rekordu z id 4 z tabeli users_accounts w polu $user jest wartość 3 (integer). Ogólnie nie mam nigdzie w bazie rekordu z id 3. Skąd ta wartość się bierze ?

Pozdrawiam.