Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node classes with inheritance not handled well #25

Open
dmarjenburgh opened this issue Apr 5, 2013 · 0 comments
Open

Node classes with inheritance not handled well #25

dmarjenburgh opened this issue Apr 5, 2013 · 0 comments

Comments

@dmarjenburgh
Copy link

I have the following metadata for the class that implements the Node interface:

<entity name="OrganisationEntity" table="org_entity" inheritance-type="SINGLE_TABLE">
<discriminator-column name="type" column="type" type="string" />
    <discriminator-map>
      <discriminator-mapping value="company" class="Company" />
      <discriminator-mapping value="branch" class="Branch" />
      <discriminator-mapping value="store" class="Store" />
    </discriminator-map>

So the class OrganisationEntity implements the Node interface and the classes Company, Branch and Store are direct subclasses. When an entity is retrieved from the DB it is an instance of the appropriate class. Now when a branch has several stores as descendents and I want to delete the branch, it will NOT delete the stores. The reason is that delete() (and several other calls) pass the class: get_class($this->getNode()) to the querybuilder. Therefore, deleting a Branch will not delete the stores, because these are different classes.

I have made the same changes that were done to shiftRLRange in commit c84f0d9 (Little fix to make it works with Inheritance) to several other calls (delete, moveBetweenTrees, etc):

  1. Added line:

    $metadata = $em->getClassMetadata(get_class($this->getNode()));
    
  2. Replaced:

    get_class($this->getNode())
    

    with
    $metadata->rootEntityName
    So far it seems to work for delete. Haven't tested the other methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant