php - Doctrine discriminator map not updating
Get the solution ↓↓↓I'm having issues with class table inheritance. I tried adding a classAtmosphereStudentRequest
which extends anotherServiceRequest
. 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 inServiceRequest
. 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 classServiceRequest
didn't haveAtmosphereStudentRequest
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
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: illegal string offset
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.