LostFocus

Hi, I'm Dominik Schwind, friend of the internet. Here is /now.
Say hello to me on Twitter or maybe even subscribe to my weekly newsletter.

I have inherited a Symfony application where two OneToOne-entities share a primary key. This is modeled in two entity classes like this:

class A
{
    /**
     * @ORM\Id
     * @ORM\OneToOne(targetEntity="App\Entity\B", inversedBy="a", cascade={"persist"}, fetch="EAGER")
     * @ORM\JoinColumn(name="id", referencedColumnName="id", nullable=false)
     */
    private B $b;
}

and

class B
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private ?int $id = null;

    /**
     * @ORM\OneToOne(targetEntity="App\Entity\A", mappedBy="b", cascade={"persist"}, fetch="EAGER")
     */
    private A $a;
}

which is not ideal but mostly works. Now there is another entity which has a more “traditional” OneToOne doctrine relationship with A:

class C
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private ?int $id = null;

    /**
     * @ORM\OneToOne(targetEntity="App\Entity\A")
     */
    private ?A $a = null;
}

But as soon as I try to use the repository class for C to fetch a C entity with find(1) everything just falls apart: Typed property App\Entity\A::$b must be an instance of App\Entity\B, int used

I am pretty sure it is either https://github.com/doctrine/orm/issues/8255 or https://github.com/doctrine/orm/issues/8745 or probably both.

There are the versions of the libraries in my composer.lock:

doctrine/annotations                 1.13.2
doctrine/cache                       2.1.1                                                                
doctrine/collections                 1.6.8                                                                
doctrine/common                      3.2.2                                                                
doctrine/dbal                        2.13.8                                                               
doctrine/deprecations                v0.5.3                                                               
doctrine/doctrine-bundle             2.5.7                                                                
doctrine/doctrine-migrations-bundle  3.2.2                                                                
doctrine/event-manager               1.1.1                                                                
doctrine/inflector                   2.0.4                                                                
doctrine/instantiator                1.4.1                                                                
doctrine/lexer                       1.2.3                                                                
doctrine/migrations                  3.3.2                                                                
doctrine/orm                         2.10.5                                                               
doctrine/persistence                 2.4.0                                                                
doctrine/sql-formatter               1.1.2                                                                

With the arrival of a little backhoe I can now proudly say that all my neighbors have or had an active construction site in the last two years. This is probably worse for my mental health than the pandemic.

With the arrival of a little backhoe I can now proudly say that all my neighbors have or had an active construction site in the last two years. This is probably worse for my mental health than the pandemic.

I thought it was a good idea to listen to the Lost Highway soundtrack first thing in the morning. Now let’s see how I am functioning at work in that mindspace.

I thought it was a good idea to listen to the Lost Highway soundtrack first thing in the morning. Now let’s see how I am functioning at work in that mindspace.

Likes https://www.youtube.com/watch?v=twAP3buj9Og.

Likes https://www.youtube.com/watch?v=twAP3buj9Og.

Who made these circles in the Sahara?

Someone left these marks in the sand. We had to find out who.Subscribe and turn on notifications 🔔 so you don't miss any videos: http://goo.gl/0bsAjO Deep i...

Who made these circles in the Sahara?

Likes https://www.youtube.com/watch?v=2paNFnw1wRs.

Likes https://www.youtube.com/watch?v=2paNFnw1wRs.

【UE5】etchū-daimon station - 越中大門駅

My latest environment, freely based on a real-life train station in Toyama, Japan.The environment is running in Unreal Engine 5, lit with Lumen. I didn't use...

【UE5】etchū-daimon station - 越中大門駅

Likes https://www.youtube.com/watch?v=5Eqb_-j3FDA.

Likes https://www.youtube.com/watch?v=5Eqb_-j3FDA.

Coke Studio | Season 14 | Pasoori | Ali Sethi x Shae Gill

Let’s transcend boundaries and bridge distances through compassion, love and identity.#Pasoori #RealMagic #CokeStudioSeason14 #SoundOfTheNationListen on Spot...

Coke Studio | Season 14 | Pasoori | Ali Sethi x Shae Gill

Likes https://www.youtube.com/watch?v=2saWSGoWmrU.

Likes https://www.youtube.com/watch?v=2saWSGoWmrU.

PSY - '이제는 (Now)' feat. 화사 (Hwa Sa) Performance Video

PSY - '이제는 (Now) feat. 화사 (Hwa Sa)' Performance Video* '이제는 (Now) feat. 화사 (Hwa Sa)' is now available on all streaming platforms including Apple Music & Spo...

PSY - '이제는 (Now)' feat. 화사 (Hwa Sa) Performance Video

Ah, yes. The season of the double act “So nice to finally go back to conferences!” and a few days later “Oh no, I tested positive.” is upon us.

Ah, yes. The season of the double act “So nice to finally go back to conferences!” and a few days later “Oh no, I tested positive.” is upon us.

I’m too dumb for Knotwords and I’m not sure how to process that.

I’m too dumb for Knotwords and I’m not sure how to process that.

Likes https://manuelclaeysbouuaert.be/projects/ferrargis.html.

Likes https://manuelclaeysbouuaert.be/projects/ferrargis.html.

Likes https://www.openstreetmap.org/user/b-unicycling/diary/399082.

Likes https://www.openstreetmap.org/user/b-unicycling/diary/399082.

b-unicycling's Diary | Archaeological Discovery | OpenStreetMap

OpenStreetMap is a map of the world, created by people like you and free to use under an open license.

b-unicycling's Diary | Archaeological Discovery | OpenStreetMap

Likes https://www.youtube.com/watch?v=8dJyRm2jJ-U.

Likes https://www.youtube.com/watch?v=8dJyRm2jJ-U.

PSY - 'That That (prod. & feat. SUGA of BTS)' MV

PSY - 'That That (prod. & feat. SUGA of BTS)' MV MV Executive Producer: P NATION MV Director: 최용석 @LUMPENSComposed by: SUGA, PSY, EL CAPITXNLyrics by: PSY, S...

PSY - 'That That (prod. & feat. SUGA of BTS)' MV

Likes https://www.youtube.com/watch?v=0bjni1f4d7Y.

Likes https://www.youtube.com/watch?v=0bjni1f4d7Y.

MONDO GROSSO / 惑星タントラ [Vocal:齋藤飛鳥(乃木坂46)] (TANTRAVE Mix) XR DJ LIVE @NEWVIEW DOMMUNE

1/29に生配信された、XRクリエイティブプラットフォーム「STYLY」とDOMMUNEのコラボ実験番組「NEWVIEW DOMMUNE」でのMONDO GROSSO XR DJ LIVEから「惑星タントラ [Vocal:齋藤飛鳥(乃木坂46)]」の映像。MONDO GROSSO XR DJ LIVEDJ: Sh...

MONDO GROSSO / 惑星タントラ [Vocal:齋藤飛鳥(乃木坂46)] (TANTRAVE Mix) XR DJ LIVE @NEWVIEW DOMMUNE

Likes https://www.emilygorcenski.com/post/angelheaded-hipsters-burning-for-the-ancient-heavenly-connection/.

Likes https://www.emilygorcenski.com/post/angelheaded-hipsters-burning-for-the-ancient-heavenly-connection/.

Oh great. Another neighbor has gotten some construction equipment. I’m just so, so tired.

Oh great. Another neighbor has gotten some construction equipment.

I’m just so, so tired.