ssossossossosso

Forums

Forums OroPlatform OroPlatform – Programming Questions Add a many to one inverse relation against core entity

This topic contains 3 replies, has 2 voices, and was last updated by  Mike Kudelya 1 year, 2 months ago.

  • Creator
    Topic
  • #28802

    franconob
    Participant

    Hello guys, I’m trying to add an inverse relation to a many to one relation. This is my custom class:

    This is my migration script:

    The addManyToOne relation method works fine. But when the migration command executes the addManyToOneInverseRelation, I get the following error:

    [Doctrine\ORM\Mapping\MappingException]
    The association mapping ‘balances’ misses the ‘targetEntity’ attribute.

    What am I doing wrong? Is this a bug? I just want this inverse relation to use the “balances” association field in a query builder.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #28803

    Mike Kudelya
    Moderator

    Hi

    I have created similar migration:

    and it successfully executed, but if i remove addManyToOneRelation call, script fails with our error.
    Did you try execute our migration twice? Try to run this migration on brand new database. When you want to have relations between your Balance and other entities please set your entity as extended. Just create ExtendBalance class in /Model folder and extend Balance from ExtendBalance. You can look at User entity, how it made there.

    #28804

    franconob
    Participant

    Hello Mike, thanks for your help. I’m currently in a new database. I’m also using orocommerce 1.0.0-beta.3, not OroCRM, could it be a problem? I’ve not created an extended entity, maybe that’s the real problem. I’m going to try that and I’ll let you know.

    Thanks!

    #28805

    Mike Kudelya
    Moderator

    Hi

    Also is not necessary to add $account property with getters and setters on Balance entity. They will be automatically created in your Balance Extended class, try to search it in app/cache/[dev or prod]/oro_entities/Extend/Entity directory.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.