Entity#parents is not an association with a single join column #5691

Closed
opened 2026-01-22 15:14:38 +01:00 by admin · 7 comments
Owner

Originally created by @bordeux on GitHub (Sep 7, 2017).

I wrote library to fetch geoNames to database for doctrine. It works fine, but when i want run tests i received this error:

Doctrine\ORM\Mapping\MappingException: 'Bordeux\Bundle\GeoNameBundle\Entity\GeoName#parents' is not an association with a single join column.

Here is result from travis-ci: https://travis-ci.org/bordeux/geoname-bundle/jobs/270466374

I dont know what that message exactly means, because from my side everything is correct.

This is my definition of paretns field:

/**
 * @var Hierarchy[]
 *
 * @ORM\OneToMany(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\Hierarchy", mappedBy="child")
 */
protected $parents;

And that is definition in hierarchy:

/**
 * @var GeoName
 *
 * @ORM\ManyToOne(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\GeoName", inversedBy="parents")
 * @ORM\JoinColumn(name="child_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
 */
protected $child;

Source: https://github.com/bordeux/geoname-bundle/tree/master/Entity

Originally created by @bordeux on GitHub (Sep 7, 2017). I wrote library to fetch geoNames to database for doctrine. It works fine, but when i want run tests i received this error: > Doctrine\ORM\Mapping\MappingException: 'Bordeux\Bundle\GeoNameBundle\Entity\GeoName#parents' is not an association with a single join column. Here is result from travis-ci: https://travis-ci.org/bordeux/geoname-bundle/jobs/270466374 I dont know what that message exactly means, because from my side everything is correct. This is my definition of paretns field: <pre code=php> /** * @var Hierarchy[] * * @ORM\OneToMany(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\Hierarchy", mappedBy="child") */ protected $parents; </pre> And that is definition in hierarchy: <pre> /** * @var GeoName * * @ORM\ManyToOne(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\GeoName", inversedBy="parents") * @ORM\JoinColumn(name="child_id", referencedColumnName="id", nullable=true, onDelete="CASCADE") */ protected $child; </pre> Source: https://github.com/bordeux/geoname-bundle/tree/master/Entity
admin closed this issue 2026-01-22 15:14:38 +01:00
Author
Owner

@Ocramius commented on GitHub (Sep 7, 2017):

What's the full exception trace?

On 7 Sep 2017 12:00, "Krzysztof Bednarczyk" notifications@github.com
wrote:

I wrote library to fetch geoNames to database for doctrine. It works fine,
but when i want run tests i received this error:

Doctrine\ORM\Mapping\MappingException: 'Bordeux\Bundle\GeoNameBundle\Entity\GeoName#parents'
is not an association with a single join column.

Here is result from travis-ci: https://travis-ci.org/bordeux/
geoname-bundle/jobs/270466374

I dont know what that message exactly means, because from my side
everything is correct.

This is my definition of paretns field:

/**

  • @var Hierarchy[]
  • @ORM\OneToMany(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\Hierarchy", mappedBy="child")
    */
    protected $parents;

And that is definition in hierarchy:

/**

  • @var GeoName
  • @ORM\ManyToOne(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\GeoName",
    inversedBy="parents")
  • @ORM\JoinColumn(name="child_id", referencedColumnName="id",
    nullable=true, onDelete="CASCADE")
    */
    protected $child;

Source: https://github.com/bordeux/geoname-bundle/tree/master/Entity


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6693, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakPyFjfd6ZRd7T7c7oNCjbekNJtmqks5sf76egaJpZM4PPlD4
.

@Ocramius commented on GitHub (Sep 7, 2017): What's the full exception trace? On 7 Sep 2017 12:00, "Krzysztof Bednarczyk" <notifications@github.com> wrote: > I wrote library to fetch geoNames to database for doctrine. It works fine, > but when i want run tests i received this error: > > Doctrine\ORM\Mapping\MappingException: 'Bordeux\Bundle\GeoNameBundle\Entity\GeoName#parents' > is not an association with a single join column. > > Here is result from travis-ci: https://travis-ci.org/bordeux/ > geoname-bundle/jobs/270466374 > > I dont know what that message exactly means, because from my side > everything is correct. > > This is my definition of paretns field: > > /** > * @var Hierarchy[] > * > * @ORM\OneToMany(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\Hierarchy", mappedBy="child") > */ > protected $parents; > > And that is definition in hierarchy: > > /** > > - @var GeoName > - > - @ORM\ManyToOne(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\GeoName", > inversedBy="parents") > - @ORM\JoinColumn(name="child_id", referencedColumnName="id", > nullable=true, onDelete="CASCADE") > */ > protected $child; > > Source: https://github.com/bordeux/geoname-bundle/tree/master/Entity > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/6693>, or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakPyFjfd6ZRd7T7c7oNCjbekNJtmqks5sf76egaJpZM4PPlD4> > . >
Author
Owner

@bordeux commented on GitHub (Sep 7, 2017):


1) Bordeux\Bundle\GeoNameBundle\Tests\Command\ImportCommandTest::testDownload
Doctrine\ORM\Mapping\MappingException: 'Bordeux\Bundle\GeoNameBundle\Entity\GeoName#parents' is not an association with a single join column.

/home/travis/build/bordeux/geoname-bundle/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php:600
/home/travis/build/bordeux/geoname-bundle/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:2859
/home/travis/build/bordeux/geoname-bundle/Import/GeoNameImport.php:237
/home/travis/build/bordeux/geoname-bundle/Import/GeoNameImport.php:74
/home/travis/build/bordeux/geoname-bundle/Import/GeoNameImport.php:49
/home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:246
/home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:223
/home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:267
/home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:225
/home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:62
/home/travis/build/bordeux/geoname-bundle/Command/ImportCommand.php:218
/home/travis/build/bordeux/geoname-bundle/vendor/symfony/console/Command/Command.php:264
/home/travis/build/bordeux/geoname-bundle/Tests/Command/ImportCommandTest.php:40
@bordeux commented on GitHub (Sep 7, 2017): <pre> 1) Bordeux\Bundle\GeoNameBundle\Tests\Command\ImportCommandTest::testDownload Doctrine\ORM\Mapping\MappingException: 'Bordeux\Bundle\GeoNameBundle\Entity\GeoName#parents' is not an association with a single join column. /home/travis/build/bordeux/geoname-bundle/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php:600 /home/travis/build/bordeux/geoname-bundle/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:2859 /home/travis/build/bordeux/geoname-bundle/Import/GeoNameImport.php:237 /home/travis/build/bordeux/geoname-bundle/Import/GeoNameImport.php:74 /home/travis/build/bordeux/geoname-bundle/Import/GeoNameImport.php:49 /home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:246 /home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:223 /home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:267 /home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:225 /home/travis/build/bordeux/geoname-bundle/vendor/guzzlehttp/promises/src/Promise.php:62 /home/travis/build/bordeux/geoname-bundle/Command/ImportCommand.php:218 /home/travis/build/bordeux/geoname-bundle/vendor/symfony/console/Command/Command.php:264 /home/travis/build/bordeux/geoname-bundle/Tests/Command/ImportCommandTest.php:40 </pre>
Author
Owner

@Ocramius commented on GitHub (Sep 7, 2017):

home/travis/build/bordeux/geoname-bundle/Import/GeoNameImport.php:237

What is this doing?

@Ocramius commented on GitHub (Sep 7, 2017): > `home/travis/build/bordeux/geoname-bundle/Import/GeoNameImport.php:237` What is this doing?
Author
Owner

@bordeux commented on GitHub (Sep 7, 2017):

Yeah, that was my issue... , Thank you

@bordeux commented on GitHub (Sep 7, 2017): Yeah, that was my issue... , Thank you
Author
Owner

@Ocramius commented on GitHub (Sep 7, 2017):

So? What was it?

@Ocramius commented on GitHub (Sep 7, 2017): So? What was it?
Author
Owner

@bordeux commented on GitHub (Sep 7, 2017):

I did foult here :


    /**
     * @return string[]
     * @author Chris Bednarczyk 
     */
    public function getFieldNames()
    {
        $metaData = $this->em->getClassMetadata("BordeuxGeoNameBundle:GeoName");
        $result = [];
        foreach ($metaData->getFieldNames() as $name) {
            $result[$name] = $metaData->getColumnName($name);
        }
        foreach ($metaData->getAssociationNames() as $name) {
                $result[$name] = $metaData->getSingleAssociationJoinColumnName($name);
        }
        return $result;
    }

should be :

 

    /**
     * @return string[]
     * @author Chris Bednarczyk 
     */
    public function getFieldNames()
    {
        $metaData = $this->em->getClassMetadata("BordeuxGeoNameBundle:GeoName");
        $result = [];
        foreach ($metaData->getFieldNames() as $name) {
            $result[$name] = $metaData->getColumnName($name);
        }
        foreach ($metaData->getAssociationNames() as $name) {
            if($metaData->isSingleValuedAssociation($name)){
                $result[$name] = $metaData->getSingleAssociationJoinColumnName($name);
            }
        }
        return $result;
    }

@bordeux commented on GitHub (Sep 7, 2017): I did foult here : <pre> /** * @return string[] * @author Chris Bednarczyk <chris@tourradar.com> */ public function getFieldNames() { $metaData = $this->em->getClassMetadata("BordeuxGeoNameBundle:GeoName"); $result = []; foreach ($metaData->getFieldNames() as $name) { $result[$name] = $metaData->getColumnName($name); } foreach ($metaData->getAssociationNames() as $name) { $result[$name] = $metaData->getSingleAssociationJoinColumnName($name); } return $result; } </pre> should be : <pre> /** * @return string[] * @author Chris Bednarczyk <chris@tourradar.com> */ public function getFieldNames() { $metaData = $this->em->getClassMetadata("BordeuxGeoNameBundle:GeoName"); $result = []; foreach ($metaData->getFieldNames() as $name) { $result[$name] = $metaData->getColumnName($name); } foreach ($metaData->getAssociationNames() as $name) { if($metaData->isSingleValuedAssociation($name)){ $result[$name] = $metaData->getSingleAssociationJoinColumnName($name); } } return $result; } </pre>
Author
Owner

@Ocramius commented on GitHub (Sep 7, 2017):

@bordeux thanks for clarifying!

@Ocramius commented on GitHub (Sep 7, 2017): @bordeux thanks for clarifying!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5691