[PR #265] [CLOSED] [WIP] Mapping support for Embeddables (VOs). #7938

Open
opened 2026-01-22 15:57:39 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/265
Author: @guilhermeblanco
Created: 1/20/2012
Status: Closed

Base: masterHead: DDC-93


📝 Commits (3)

  • 5ef2395 Mapping support for Embeddables (VOs).
  • d519074 First round of refactorings after initial commit about VOs implementation after some valuable comments.
  • cc960ba More work around Value Objects.

📊 Changes

20 files changed (+748 additions, -135 deletions)

View changed files

📝 doctrine-mapping.xsd (+66 -43)
📝 lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php (+45 -9)
📝 lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (+241 -29)
📝 lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php (+19 -4)
📝 lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php (+2 -0)
📝 lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php (+20 -0)
📝 lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php (+19 -0)
lib/Doctrine/ORM/Mapping/Embeddable.php (+28 -0)
lib/Doctrine/ORM/Mapping/Embedded.php (+33 -0)
📝 lib/Doctrine/ORM/Mapping/MappingException.php (+15 -1)
📝 lib/Doctrine/ORM/Persisters/BasicEntityPersister.php (+132 -37)
📝 lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php (+12 -3)
📝 lib/Doctrine/ORM/Tools/SchemaTool.php (+36 -0)
📝 lib/vendor/doctrine-dbal (+1 -1)
tests/Doctrine/Tests/Models/CMS/CmsParents.php (+34 -0)
📝 tests/Doctrine/Tests/Models/CMS/CmsUser.php (+4 -0)
📝 tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php (+24 -0)
📝 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php (+4 -0)
📝 tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml (+9 -7)
📝 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml (+4 -1)

📄 Description

This patch is going to address: http://www.doctrine-project.org/jira/browse/DDC-93

Embeddable classes are a good way for organizing your domain model. Specially larger systems, which contains similar domain objects with similar properties.
This patch proposes a cleaner way to structure these duplicating attributes (and logic) into an @Embeddable object. Abstract the common information into an @Embeddedable object and use it as @Embedded.

/**
 * @Embeddable
 */
class Location
{
    /** @Column(type="decimal", scale=8, precision=12, nullable=true) */
    protected $latitude;

    /** @Column(type="decimal", scale=8, precision=12, nullable=true) */
    protected $longitude;
}

/**
 * @Entity 
 */
class User
{
    /** @Id @GeneratedValue @Column(type="integer") */
    protected $id;

    // ...

    /** @Embedded(class="Location") */
    protected $location;
}

Querying:

$query = $entityManager->createQuery('SELECT u FROM User u WHERE u.location.latitude = ?1');

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/265 **Author:** [@guilhermeblanco](https://github.com/guilhermeblanco) **Created:** 1/20/2012 **Status:** ❌ Closed **Base:** `master` ← **Head:** `DDC-93` --- ### 📝 Commits (3) - [`5ef2395`](https://github.com/doctrine/orm/commit/5ef2395dee388721885f5280455d8a60c9f4fa7f) Mapping support for Embeddables (VOs). - [`d519074`](https://github.com/doctrine/orm/commit/d519074e1838189c554d006749c48632871dcc59) First round of refactorings after initial commit about VOs implementation after some valuable comments. - [`cc960ba`](https://github.com/doctrine/orm/commit/cc960bab8552c1f376bef6234822f6eb6a173855) More work around Value Objects. ### 📊 Changes **20 files changed** (+748 additions, -135 deletions) <details> <summary>View changed files</summary> 📝 `doctrine-mapping.xsd` (+66 -43) 📝 `lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php` (+45 -9) 📝 `lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php` (+241 -29) 📝 `lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php` (+19 -4) 📝 `lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php` (+2 -0) 📝 `lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php` (+20 -0) 📝 `lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php` (+19 -0) ➕ `lib/Doctrine/ORM/Mapping/Embeddable.php` (+28 -0) ➕ `lib/Doctrine/ORM/Mapping/Embedded.php` (+33 -0) 📝 `lib/Doctrine/ORM/Mapping/MappingException.php` (+15 -1) 📝 `lib/Doctrine/ORM/Persisters/BasicEntityPersister.php` (+132 -37) 📝 `lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php` (+12 -3) 📝 `lib/Doctrine/ORM/Tools/SchemaTool.php` (+36 -0) 📝 `lib/vendor/doctrine-dbal` (+1 -1) ➕ `tests/Doctrine/Tests/Models/CMS/CmsParents.php` (+34 -0) 📝 `tests/Doctrine/Tests/Models/CMS/CmsUser.php` (+4 -0) 📝 `tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php` (+24 -0) 📝 `tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php` (+4 -0) 📝 `tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml` (+9 -7) 📝 `tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml` (+4 -1) </details> ### 📄 Description This patch is going to address: http://www.doctrine-project.org/jira/browse/DDC-93 Embeddable classes are a good way for organizing your domain model. Specially larger systems, which contains similar domain objects with similar properties. This patch proposes a cleaner way to structure these duplicating attributes (and logic) into an @Embeddable object. Abstract the common information into an @Embeddedable object and use it as @Embedded. ``` php /** * @Embeddable */ class Location { /** @Column(type="decimal", scale=8, precision=12, nullable=true) */ protected $latitude; /** @Column(type="decimal", scale=8, precision=12, nullable=true) */ protected $longitude; } /** * @Entity */ class User { /** @Id @GeneratedValue @Column(type="integer") */ protected $id; // ... /** @Embedded(class="Location") */ protected $location; } ``` Querying: ``` php $query = $entityManager->createQuery('SELECT u FROM User u WHERE u.location.latitude = ?1'); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 15:57:39 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7938