# doctrine: A new entity was found through the relationship

**URL:** <https://forum.shopware.com/t/doctrine-a-new-entity-was-found-through-the-relationship/23688>\
**Category:** Shopware 3.5\
**Tags:** programming\
**Created:** [19. November 2014 um 18:59 UTC](https://forum.shopware.com/t/doctrine-a-new-entity-was-found-through-the-relationship/23688 "2014-11-19T18:59:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![codefritz](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@codefritz](https://forum.shopware.com/u/codefritz)\
**Post date:** [19. November 2014 um 18:59 UTC](https://forum.shopware.com/t/doctrine-a-new-entity-was-found-through-the-relationship/23688/1 "2014-11-19T18:59:10Z")

</div>

Ich habe zwei einfach Entities, diese sind über eine ManyToMany Verknüpfung verbunden. wenn ich nun nachfolgenden Code ausführe, kommt stets die Fehlermeldung: A new entity was found through the relationship ‘Shopware\CustomModels\JoeKaffeeAbo\Client#abos’ that was not configured to cascade persist operations for entity: Shopware\CustomModels\JoeKaffeeAbo\Abo@00000000211b173900000000cf7658ac. `$client = new Client(); $client-\>setCustomerid(12); $client-\>setCustomernumber(12); $client-\>setIs\_active(true); Shopware()-\>Models()-\>persist($client); $abo = new Abo(); $abo-\>setName("name"); $abo-\>setDesc("desc"); $abo-\>setName\_en("name"); $abo-\>setDesc\_en("desc"); $client-\>addAbo($abo); //$abo-\>addClient($client); //$client-\>addAbo($abo); Shopware()-\>Models()-\>persist($client); //Shopware()-\>Models()-\>persist($abo); Shopware()-\>Models()-\>flush();` Die Models sehen folgendermaßen aus: [code]\<?php namespace Shopware\CustomModels\JoeKaffeeAbo;

use Symfony\Component\Validator\Constraints as Assert,  
Doctrine\Common\Collections\ArrayCollection,  
Shopware\Components\Model\ModelEntity,  
Doctrine\ORM\Mapping AS ORM;

/\*\*

- @ORM\Entity

- @ORM\Table(name=“joe\_kaffee\_abo\_abos”)  
\*/  
class Abo extends ModelEntity  
{

use Symfony\Component\Validator\Constraints as Assert,  
Doctrine\Common\Collections\ArrayCollection,  
Shopware\Components\Model\ModelEntity,  
Doctrine\ORM\Mapping AS ORM;

/\*\*

- @ORM\Entity

- @ORM\Table(name=“joe\_kaffee\_abo\_client”)  
\*/  
class Client extends ModelEntity  
{

---

<div class="post-metadata">

**Author:** ![EikeBrandtWarneke](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@EikeBrandtWarneke](https://forum.shopware.com/u/EikeBrandtWarneke)\
**Post date:** [19. November 2014 um 20:03 UTC](https://forum.shopware.com/t/doctrine-a-new-entity-was-found-through-the-relationship/23688/2 "2014-11-19T20:03:45Z")

</div>

Bei dir fehlt die Angabe der Kreuz-Tabelle. Schau mal in Doku von doctrine oder in die Shopware Beispiele. Gesendet von meinem iPhone mit Tapatalk

---

<div class="post-metadata">

**Author:** ![codefritz](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@codefritz](https://forum.shopware.com/u/codefritz)\
**Post date:** [19. November 2014 um 20:26 UTC](https://forum.shopware.com/t/doctrine-a-new-entity-was-found-through-the-relationship/23688/3 "2014-11-19T20:26:52Z")

</div>

Ich hab auf der owning Seite die Kreuztabelle hinzugefügt: \* @ORM\JoinTable(name=“joe\_abos\_clients”) funktioniert trotzdem nicht.

---

<div class="post-metadata">

**Author:** ![EikeBrandtWarneke](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@EikeBrandtWarneke](https://forum.shopware.com/u/EikeBrandtWarneke)\
**Post date:** [20. November 2014 um 09:17 UTC](https://forum.shopware.com/t/doctrine-a-new-entity-was-found-through-the-relationship/23688/4 "2014-11-20T09:17:50Z")

</div>

Der erste google Treffer mit der Suche „shopware doctrine“ erklärt Schritt für Schritt den Umhang mit doctrine Models: [http://wiki.shopware.com/Shopware-4-Mod … l\_982.html](http://wiki.shopware.com/Shopware-4-Models%5C_detail%5C_982.html) Gesendet von meinem iPhone mit Tapatalk

---

<div class="post-metadata">

**Author:** ![codefritz](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@codefritz](https://forum.shopware.com/u/codefritz)\
**Post date:** [20. November 2014 um 10:41 UTC](https://forum.shopware.com/t/doctrine-a-new-entity-was-found-through-the-relationship/23688/5 "2014-11-20T10:41:22Z")

</div>

Ja dieses Tutorial kenne ich schon und habe ich auch schon durchgearbeitet. Ich hab mich bei allen Defitionen/Annotations etc daran gehalten, kriege aber dennoch diesen Fehler. Auch auf [doctrine-project.org](http://doctrine-project.org) habe ich schon einige Tutorials durchgearbeitet aber ich bin leider an einem Punkt angekommen wo ich nicht mehr weiter weiß. Hast Du Dir mein Model schonmal angeguckt, habe ich irgendwas übersehen?
