Hello, I am beginig to develop my first app i Symfony3 and Doctrine and I came up against a problem I cannot solve.
I am trying to join three entities with one-to-many/many-to-one associations. The broblem is quite similar to this https://groups.google.com/d/msg/doctrine-user/0dh8lgUudvc/-NB_cOXT9ggJ I understand the concpet and I believe I managed to create appropriate entities but somehow when I try to load fixtures as an example data I get a Doctrine Exception php app/console hautelook_alice:doctrine:fixtures:load > Found entity of type AppBundle\Entity\ItemOwner on association >> AppBundle\Entity\ItemOwner#item, but expecting AppBundle\Entity\Item > > Is there anything wrong I am doing or is it just fixture loader can't handle my fixtures AppBundle\Entity\Item: item_{1..20}: name (unique): <randomElement(['KEFE','CEFE','KIDS','KDFJ','CDFJ'])><randomElement(['1-50','51-100','151-200','1-25','26-50','51-75','76-100','101-125','126-150'])> itemOrder: <randomDigitNotNull()> itemType: @item_type* status: 1 createdAt: <dateTimeBetween('-200 days', 'now')> updatedAt: <dateTimeBetween($createdAt, 'now')> AppBundle\Entity\Owner: owner_{1..10}: name (unique): <name()> status: 1 createdAt: <dateTimeBetween('-200 days', 'now')> updatedAt: <dateTimeBetween($createdAt, 'now')> AppBundle\Entity\ItemOwner: item_owner_{1..100}: item: @item* owner: @owner* number: <numberBetween(1, 200)> issued: <dateTimeBetween('-10 years', 'now')> comment: <sentence(6, true)> createdAt: <dateTimeBetween('-200 days', 'now')> updatedAt: <dateTimeBetween($createdAt, 'now')> Thank you in advance for your time you took to help me Here are my 3 entites [ITEM] use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** * Item * * @ORM\Table(name="item") * @ORM\Entity(repositoryClass="AppBundle\Repository\ItemRepository") */ class Item { /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=255, unique=true) */ private $name; /** * @var int * * @ORM\Column(name="item_order", type="integer") */ private $itemOrder; /** * @var ItemType; * * @ORM\ManyToOne(targetEntity="ItemType") * @ORM\JoinColumn(name="item_type", referencedColumnName="id") */ private $itemType; /** * @var int * * @ORM\Column(name="status", type="integer") */ private $status; /** * @var \DateTime * * @ORM\Column(name="created_at", type="datetime") */ private $createdAt; /** * @var \DateTime * * @ORM\Column(name="updated_at", type="datetime") */ private $updatedAt; /** * @var ArrayCollection; * * @ORM\OneToMany(targetEntity="ItemOwner", mappedBy="item") */ private $itemOwners; public function __construct() { $this->itemOwners = new ArrayCollection(); } ...SETTERS/GETTERS [OWNER] use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** * Owner * * @ORM\Table(name="owner") * @ORM\Entity(repositoryClass="AppBundle\Repository\OwnerRepository") */ class Owner { /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=255, unique=true) */ private $name; /** * @var int * * @ORM\Column(name="status", type="integer") */ private $status; /** * @var \DateTime * * @ORM\Column(name="created_at", type="datetime") */ private $createdAt; /** * @var \DateTime * * @ORM\Column(name="updated_at", type="datetime") */ private $updatedAt; /** * @var ArrayCollection; * * @ORM\OneToMany(targetEntity="ItemOwner", mappedBy="owner") */ private $itemOwners; public function __construct() { $this->itemOwners = new ArrayCollection(); } ...SETTERS/GETTERS [ItemOwner] use Doctrine\ORM\Mapping as ORM; /** * ItemOwner * * @ORM\Table(name="item_to_owner",uniqueConstraints={ * @ORM\UniqueConstraint(name="owning_idx", columns={"owner_id", "item_id","number"})}) * @ORM\Entity(repositoryClass="AppBundle\Repository\ItemOwnerRepository") */ class ItemOwner { /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\ManyToOne(targetEntity="Item", inversedBy="itemOwners") * @ORM\JoinColumn(name="item_id", referencedColumnName="id") */ private $item; /** * @ORM\ManyToOne(targetEntity="Owner", inversedBy="itemOwners") * @ORM\JoinColumn(name="owner_id", referencedColumnName="id") */ private $owner; /** @ORM\Column(type="integer") */ private $number; /** @ORM\Column(name="issued", type="string", length=255) */ private $issued; /** @ORM\Column(name="comment", type="text") */ private $comment; /** * @var \DateTime * * @ORM\Column(name="created_at", type="datetime") */ private $createdAt; /** * @var \DateTime * * @ORM\Column(name="updated_at", type="datetime") */ private $updatedAt; -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
