# Persistieren einer Assoziation

**URL:** https://forum.shopware.com/t/persistieren-einer-assoziation/68848
**Category:** Programmierung
**Created:** [7. August 2020 um 12:46 UTC](https://forum.shopware.com/t/persistieren-einer-assoziation/68848 "2020-08-07T12:46:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![euroxid](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/euroxid/32/15105_2.png) [@euroxid](https://forum.shopware.com/u/euroxid)
#### Post date: [7. August 2020 um 12:46 UTC](https://forum.shopware.com/t/persistieren-einer-assoziation/68848/1 "2020-08-07T12:46:26Z")

</div>

Ich habe gemäß Bundle-Tutorial eine Assoziation aufgebaut, und versuche nun meinem Entity die Assoziation mitzugeben:

&nbsp;

> /\*\* @var EntityRepositoryInterface $productsRepository \*/ $productsRepository = $container-\>get(ProductDefinition::ENTITY\_NAME . ‚.repository‘); $products = $productsRepository-\>search( (new Criteria())-\>addFilter(new ContainsFilter(‚name‘, ‚ProteX‘)), Context::createDefaultContext() ); /\*\* \* @var ProductEntity $firstProduct \*/ $firstProduct = $products-\>first(); ///////////////////////////////////////////// $myEntity-\>setProducts($products-\>getEntities());

&nbsp;

Wenn ich nun sofort $myEntity-\>getProducts() aufrufe, sehe ich die Daten. In der Datenbanktabelle acme\_myentity\_product&nbsp;kommt aber nichts an. Muss ich etwas persistieren/flushen?&nbsp;

&nbsp;

Danke
