DDC-588: EntityManager::refresh fails when ID columnName differs from fieldName #723

Closed
opened 2026-01-22 12:48:07 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (May 14, 2010).

Jira issue originally created by user @hobodave:

Reproduce:

/****
 * @Entity
 * @Table(name="site")
 */
class Site
{
    /****
     * @Id
     * @Column(type="integer", name="site_id")
     * @GeneratedValue
     */
    protected $id;

    /*** @Column(type="string",length=45, unique=true) **/
    protected $name;

    public function **construct($name = '')
    {
        $this->name = $name;
    }
}

$site = new Site('Foo');
$em->persist($site);
$em->flush();
$em->refresh($site);

Result:

Doctrine\ORM\ORMException: Unrecognized field: site_id

/Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/ORMException.php:45
/Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:1042
/Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:783
/Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:571
/Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/UnitOfWork.php:1485
/Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/UnitOfWork.php:1461
/Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/EntityManager.php:431
/Users/hobodave/dev/work/S5/tests/application/modules/common/services/SiteServiceTest.php:69
Originally created by @doctrinebot on GitHub (May 14, 2010). Jira issue originally created by user @hobodave: Reproduce: ``` /**** * @Entity * @Table(name="site") */ class Site { /**** * @Id * @Column(type="integer", name="site_id") * @GeneratedValue */ protected $id; /*** @Column(type="string",length=45, unique=true) **/ protected $name; public function **construct($name = '') { $this->name = $name; } } $site = new Site('Foo'); $em->persist($site); $em->flush(); $em->refresh($site); ``` Result: ``` Doctrine\ORM\ORMException: Unrecognized field: site_id /Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/ORMException.php:45 /Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:1042 /Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:783 /Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:571 /Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/UnitOfWork.php:1485 /Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/UnitOfWork.php:1461 /Users/hobodave/dev/work/doctrine2/lib/Doctrine/ORM/EntityManager.php:431 /Users/hobodave/dev/work/S5/tests/application/modules/common/services/SiteServiceTest.php:69 ```
admin added the Bug label 2026-01-22 12:48:07 +01:00
admin closed this issue 2026-01-22 12:48:08 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 14, 2010):

Comment created by @hobodave:

Fixed in branch DDC-588

http://github.com/hobodave/doctrine2/commit/edf096eb57437521bbc40e49bcfc3fdbd747b501

@doctrinebot commented on GitHub (May 14, 2010): Comment created by @hobodave: Fixed in branch [DDC-588](http://www.doctrine-project.org/jira/browse/DDC-588) http://github.com/hobodave/doctrine2/commit/edf096eb57437521bbc40e49bcfc3fdbd747b501
Author
Owner

@doctrinebot commented on GitHub (May 16, 2010):

Comment created by @beberlei:

Is this fixed now or not?

@doctrinebot commented on GitHub (May 16, 2010): Comment created by @beberlei: Is this fixed now or not?
Author
Owner

@doctrinebot commented on GitHub (May 16, 2010):

Comment created by romanb:

I think so. If not please reopen.

@doctrinebot commented on GitHub (May 16, 2010): Comment created by romanb: I think so. If not please reopen.
Author
Owner

@doctrinebot commented on GitHub (May 16, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (May 16, 2010): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#723