Load class metadata change problem #5477

Closed
opened 2026-01-22 15:08:47 +01:00 by admin · 6 comments
Owner

Originally created by @danitome24 on GitHub (Mar 27, 2017).

Hi,

I'm developing with DDD and doctrine and I would use embeddable for Value Objects. In my code, there are some Value Objects that I could reuse but due to a legacy code, these columns on database are different named. So I thought that I could update it on loadClassMetadata doctrine event. I also use Symfony.

To get this achievement I've started only assigning the embeddable to an entity from doctrine event like the following:
image

This code works and on dump I can see the embeddable Location object into embeddables array. The problem is when I fetch something and this Value Object (location) is null on my entity (Hotel).

Something wrong?

Versions:

Package Vendor
Doctrine 2.5.4
Symfony 3.2.1
Originally created by @danitome24 on GitHub (Mar 27, 2017). Hi, I'm developing with DDD and doctrine and I would use embeddable for Value Objects. In my code, there are some Value Objects that I could reuse but due to a legacy code, these columns on database are different named. So I thought that I could update it on `loadClassMetadata` doctrine event. I also use Symfony. To get this achievement I've started only assigning the embeddable to an entity from doctrine event like the following: ![image](https://cloud.githubusercontent.com/assets/7501990/24343373/621354a6-12c6-11e7-8f6c-f5e9a628382b.png) This code works and on dump I can see the embeddable Location object into embeddables array. The problem is when I fetch something and this Value Object (location) is null on my entity (Hotel). Something wrong? Versions: Package | Vendor ------------ | ------------- Doctrine | 2.5.4 Symfony | 3.2.1
admin closed this issue 2026-01-22 15:08:47 +01:00
Author
Owner

@lcobucci commented on GitHub (Mar 27, 2017):

In general, what you would have to do is actually use the @AttributeOverrides annotation on you class using embeddable.attribute as name but due to the current limitation you can't really do it at the moment.

I think you're having this issue for the same reason we can't override embeddable objects.

@lcobucci commented on GitHub (Mar 27, 2017): In general, what you would have to do is actually use the `@AttributeOverrides` annotation on you class using `embeddable.attribute` as name but due to the [current limitation](https://github.com/doctrine/doctrine2/pull/6151#issuecomment-271432401) you can't really do it at the moment. I think you're having this issue for the same reason we can't override embeddable objects.
Author
Owner

@danitome24 commented on GitHub (Mar 27, 2017):

How can I use @AttributeOverrides in YAML configuration? @lcobucci

@danitome24 commented on GitHub (Mar 27, 2017): How can I use `@AttributeOverrides` in YAML configuration? @lcobucci
Author
Owner

@lcobucci commented on GitHub (Mar 27, 2017):

@danitome24 1aa02f9afc/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php (L630)

But I recommend you to move away from YAML since it's already removed from the next major release.

@lcobucci commented on GitHub (Mar 27, 2017): @danitome24 https://github.com/doctrine/doctrine2/blob/1aa02f9afcb374d7d3060f960fa8ce096bf71369/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php#L630 But I recommend you to move away from YAML since it's already removed from the next major release.
Author
Owner

@danitome24 commented on GitHub (Mar 27, 2017):

@lcobucci Two last questions:

  1. Why is YAML going to be removed? Performance?
  2. When is going to be developed this feature? I'm waiting for it... if need help...

Thanks a lot 👍

@danitome24 commented on GitHub (Mar 27, 2017): @lcobucci Two last questions: 1. Why is YAML going to be removed? Performance? 1. When is going to be developed this feature? I'm waiting for it... if need help... Thanks a lot :+1:
Author
Owner

@lcobucci commented on GitHub (Mar 27, 2017):

  1. Why is YAML going to be removed? Performance?

Also, YAML it's a mess and we had tons of invalid issues because of syntax errors. You can see more on https://github.com/doctrine/doctrine2/pull/5932#issuecomment-233593524

  1. When is going to be developed this feature? I'm waiting for it... if need help...

At the moment we're working on different things so it would be amazing if the community could send a PR to master that fixes that (maybe you?).

@lcobucci commented on GitHub (Mar 27, 2017): > 1. Why is YAML going to be removed? Performance? Also, YAML it's a mess and we had tons of invalid issues because of syntax errors. You can see more on https://github.com/doctrine/doctrine2/pull/5932#issuecomment-233593524 > 2. When is going to be developed this feature? I'm waiting for it... if need help... At the moment we're working on different things so it would be amazing if the community could send a PR to `master` that fixes that (maybe you?).
Author
Owner

@danitome24 commented on GitHub (Mar 27, 2017):

@lcobucci Thanks a lot...maybe you'll have a PR from me ;). Closing issue!!

@danitome24 commented on GitHub (Mar 27, 2017): @lcobucci Thanks a lot...maybe you'll have a PR from me ;). Closing issue!!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5477