Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9076175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:03:07+00:00 2026-06-16T19:03:07+00:00

I want to do mapping that does this: User can own multiple Games .

  • 0

I want to do mapping that does this:

User can own multiple Games. Games can have multiple owners.

I have id column in game table and game and user columns in ownership table. How I can connect these fields? I want to have game and user fields in ownership related to user and game tables.

I tried OneToMany and ManyToMany, but the first one results in generating additional columns. I don’t want to insert anything in game table.

–edit–
My @ManyToMany code:

/**
 * @ORM\ManyToMany(targetEntity="Ownership")
 * @ORM\JoinTable(name="ownership",
 *      joinColumns={JoinColumn(name="user", referencedColumnName="id")},
 *      inverseJoinColumns={JoinColumn(name="game", referencedColumnName="id")}
 *      )
 */

It causes an error in Symfony’s command line:

  [Doctrine\Common\Annotations\AnnotationException]                            
  [Semantical Error] Couldn't find constant JoinColumn, property GameShelf\Us  
  ersBundle\Entity\User::$ownership.  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:03:08+00:00Added an answer on June 16, 2026 at 7:03 pm

    Of course you need many to many relations if, like you said:

    User can own multiple Games. Games can have multiple owners.

    The Doctrine should create third table (which could contains only two foreign keys: game_id and ownership_id).

    The error is caused because Doctrine dosen’t know what JoinColumn is. You just did wrong annotation because you forgot (again! ;)) precede JoinColumn with `@ORM. The right annotation should look like this:

    /**
     * @ORM\ManyToMany(targetEntity="Ownership")
     * @ORM\JoinTable(name="ownership",
     *      joinColumns={@ORM\JoinColumn(name="user", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="game", referencedColumnName="id")}
     *      )
     */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hierarchical JPA mapping that is several Classes deep. Something like this
I want to make a cloning or mapping function where I can specify (once)
Question: I want to add a unique constraint on a mapping table (n:n). I
i have to change a sql mapping in Ibatis an I want to limit
I want to exclude a field using Dozer like this : <mapping> <class-a>com.core.model.Model</class-a> <class-b>com.core.model.ModelIS</class-b>
I have a situation where I want to create a mapping from a tuple
I have a class Tenant, which links to a User via a TenantUser table
I saw this ViewPager, compatibility package and ice cream sandwich and that Does the
I have data I need to display/edit that does not seem to fit naturally
Im looking for a simple (if I can call it that) mapping tool for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.