Doctrine discriminator map not updating

两盒软妹~` 提交于 2019-12-24 00:34:14

问题


I'm having issues with class table inheritance. I tried adding a class AtmosphereStudentRequest which extends another ServiceRequest. I'm getting the following error:

Entity 'Entities\ServiceRequest\AtmosphereStudentRequest' has to be part of the descriminator map of 'Entities\ServiceRequest' to be properly mapped in the inheritance hierachy. Alternatively you can make 'Entities\ServiceRequest\AtmosphereStudentRequest' an abstract class to avoid this exception from occuring.

The following table inheritance metadata exists in ServiceRequest. Note I'm adding a class, alongside others that existed before and work just fine.

/**                                                                                                                                        
 * @Entity(repositoryClass="Repositories\ServiceRequestRepository")                                                                        
 * @InheritanceType("JOINED")                                                                                                              
 * @DiscriminatorColumn(name="subtype", type="string")                                                                                     
 * @DiscriminatorMap({"service_request" = "ServiceRequest", "atmosphere_student_requests" = "\Entities\ServiceRequest\AtmosphereStudentRequest", "atmosphere_request" = "\Entities\ServiceRequest\AtmosphereRequest", ... })                                                                                              
 * @HasLifecycleCallbacks                                                                                                                  
 * @Table(name="service_requests",indexes={@index(name="service_request_status_idx",                                                       
 * columns={"status"})})                                                                                                                   
 */         

I dug into the code throwing the error and verified that the class ServiceRequest didn't have AtmosphereStudentRequest in its discriminator mapping list. I also noticed that my changes to the DiscriminatorMap annotation had no effect on the mapping list I was printing. Is caching the culprit? Do I need to run a command to update the new annotations?

I'm new to php, and web dev in php. I used the console doctrine tools to check if the mapping was correct. When I run, php doctrine orm:schema:update. I get the following output:

...
Array
(
    [0] => Entities\ServiceRequest
    ...
    [2] => Entities\ServiceRequest\AtmosphereStudentRequest
    [3] => Entities\ServiceRequest\AtmosphereRequest
    ...
)
...
Nothing to update - your database is already in sync with the current entity metadata.

I'm using Doctrine 1.2

来源:https://stackoverflow.com/questions/32766253/doctrine-discriminator-map-not-updating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!