php - Skip persisting of a related entity in Doctrine2 -


I have a unit "Entity 1", with one unit "One Unity 2" plus one-tone (one- Direction) is the relationship. Entity2 is managed by a separate unit manager.

Here is part of Entity1:

  / ** * @ORM \ OneToOne (targetEntity = "Entity2") * @ORM \ JoinColumn (name = "Entity2ID" Referenced columnname = "id") ** / protected $ entity2;  

Entity2 already exists, Entity1 is a new unit. Here is part of the continuing logic:

 $ obj1 = new unit 1 (); $ Obj1- & gt; SetEntity2 ($ this- & gt; Unit 2 Manager - & gt; getRepository ('Vanderbunelde: Entity 2') - & gt; Search ($ entity2Id)); $ This- & gt; Entity1Manager- & gt; ($ Obj1) continues; $ This- & gt; Entity1Manager- & gt; Flush ();  

I get this error:

  A new organization was found through the relationship 'MyBundle \\ existence \\ Entity1 # entity2' which is configured Continued waterfall for the unit was not operational: Vanderbundle \\ unit \\ Entity2 @ 0000000008fbb41600007f3bc3681401 To resolve this problem: Either call EntityManager # persist () on this unknown unit or configure Concerter Please keep this collaboration in the mapping as @ManyToOne (.., cascade = {\ "persist \"}). If you did not know which institution causes the problem to apply the problem to 'Vanderbundal' \ 'survival', then to get a clue,  

How do I assign Entity2 to Continue and keep the relationship at the same time? I tried "-> Merge ($ obj1)" This works, but when I call $ obj1-> getId (), do I get blank?!

I will try this method:

separate from one entity Is an Entity Manager and thus now it is not managed by cascading the process of applying EntityManager # detach ($ entity) method or separating it. Changes made in separate unit, if any (including deletion of institution), the unit will not be synchronized after separation.

$ obj1 = new Entity1 (); $ Obj2 = $ this- & gt; Unit 2 Manager - & gt; GetRepository ('Vanderbunelde: Entity 2') - & gt; Search ($ entity2Id); $ Obj1- & gt; SetEntity2 ($ obj2); $ This- & gt; Entity1Manager- & gt; ($ Obj2) is different; $ This- & gt; Entity1Manager- & gt; ($ Obj1) continues; $ This- & gt; Entity1Manager- & gt; Flush ();

Although not tried, please tell me that it works, thanks.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -