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

Entity class 'Talent' used in the discriminator map of class 'AppBundle\Entity\User' does not exist #4046

Closed
jbinfo opened this issue Feb 3, 2016 · 11 comments
Labels
Help Wanted Issues needing help and clarification.

Comments

@jbinfo
Copy link
Contributor

jbinfo commented Feb 3, 2016

I want to work with SyliusMailerBundle to manage mails, when I try to execute this command:

php app/console doctrine:schema:update --force

It show me this error:

[Doctrine\ORM\Mapping\MappingException]                                                               
Entity class 'Talent' used in the discriminator map of class 'AppBundle\Entity\User' does not exist. 

When I remove SyliusMailerBundle and SyliusResourceBundle from AppKernel the problem gone.

My User entity:

/**
 * @ORM\Entity
 * @ORM\Table(name="`user`")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"talent"="Talent", "company"="Company"})
 */
abstract class User extends BaseUser
{
    // ....
}

I have two types of user Talent and Company that extends the User entity.

I have found an entry on the sylius-dev Google group same problem: https://groups.google.com/forum/#!topic/sylius-dev/MgzLzgDKIxY

Any advice please, thank you.

@michalmarcinkowski michalmarcinkowski added the Help Wanted Issues needing help and clarification. label Feb 3, 2016
@michalmarcinkowski
Copy link
Contributor

Try mapping your class as MappedSuperclass.

@pjedrzejewski
Copy link
Member

@jbinfo I have never tried but I am pretty sure this won't work... having 2 different user classes with SyliusUserBundle. We would like to support it, but right now it is not the case, most likely.

@jbinfo
Copy link
Contributor Author

jbinfo commented Feb 3, 2016

@pjedrzejewski I'm working with FOSUserBundle and PUGXMultiUserBundle what I want is only the SyliusMailerBundle to manage mails.

@jbinfo
Copy link
Contributor Author

jbinfo commented Feb 3, 2016

@michalmarcinkowski Do you think if I changer User entity to be MappedSuperclass still work with FOSUserBundle ?

@pjedrzejewski
Copy link
Member

@jbinfo No, if you use FOSUserBundle then it should be fine. Did you register Company and Talent as resources in SyliusResourceBundle? It can be that SRB does not support entities with discriminator maps.

@jbinfo
Copy link
Contributor Author

jbinfo commented Feb 3, 2016

@pjedrzejewski No, I didn't register any resource, my config file:

sylius_mailer:
    driver: doctrine/orm # Configure the doctrine orm driver used in the documentation.
    sender:
        name: My website
        address: no-reply@my-website.com

Right now I don't use SRB in my app, it's just a hard dependency for SyliusMailerBundle

@pjedrzejewski
Copy link
Member

Well, then it is really strange, because Sylius bundles should not affect it then. Have you tried replacing "Talent" with full class name? (with namespace)

@jbinfo
Copy link
Contributor Author

jbinfo commented Feb 3, 2016

@michalmarcinkowski @pjedrzejewski it's working with MappedSuperclass the doctrine update command now execute without error and in database there is a table sylius_email.

My new User entity annotations definition:

/**
 * @ORM\Entity
 * @ORM\Table(name="`user`")
 * @ORM\InheritanceType("JOINED")
 * @ORM\MappedSuperclass()
 */
abstract class User extends BaseUser
{
    // ....
}

Thank you :)

@koemeet
Copy link
Contributor

koemeet commented Feb 3, 2016

@jbinfo Great you've found a solution 👍 If everything is resolved, could you close this issue please?

@jbinfo jbinfo closed this as completed Feb 3, 2016
@jbinfo
Copy link
Contributor Author

jbinfo commented Feb 3, 2016

@steffenbrem done, thank you.

@pjedrzejewski
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Issues needing help and clarification.
Projects
None yet
Development

No branches or pull requests

4 participants