OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

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 7 years, 5 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34288

    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
  • #34289

    Mike Kudelya
    Participant

    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.

    #34290

    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!

    #34291

    Mike Kudelya
    Participant

    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)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top