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

  • SEARCH
  • Home
  • 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 9273077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:01:18+00:00 2026-06-18T16:01:18+00:00

Here , there’s an explanation on How to generate Entities from an Existing Database.

  • 0

Here, there’s an explanation on “How to generate Entities from an Existing Database”.

I have a table person. And a table address. A person can have many different addresses, and an address can be related to one ore more persons. So this is a “many to many” relationship. Thus I’ve created an “in-between” table I’ve called personaddress where there’s a idPersonne and idAddress.

When launching the generation everything is fine but the many to many relationship (there are more than one).

PersonneAdresse:
    type: entity
    table: personne_adresse
    fields:
        id:
            id: true
            type: bigint
            nullable: false
            generator:
                strategy: IDENTITY
    manyToOne:
        idPersonne:
            targetEntity: Personne
            cascade: {  }
            mappedBy: null
            inversedBy: null
            joinColumns:
                id_personne:
                    referencedColumnName: id
            orphanRemoval: false
        idAdresse:
            targetEntity: Adresse
            cascade: {  }
            mappedBy: null
            inversedBy: null
            joinColumns:
                id_adresse:
                    referencedColumnName: id
            orphanRemoval: false
    lifecycleCallbacks: {  }

The documentation about oneToMany is not enough (I need an example to understand):

If you have oneToMany relationships between your entities, you will
need to edit the generated xml or yml files to add a section on the
specific entities for oneToMany defining the inversedBy and the
mappedBy pieces.

And I’m pretty sure the modification is not only about oneToMany, but manyToMany too.
Can you explain me what I should do/modify to be able to generate properly the corresponding entities?

  • 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-18T16:01:19+00:00Added an answer on June 18, 2026 at 4:01 pm

    Here’s how I did the stuff: I’ve generated the whole files, but I knew there were some ManyToMany relationships. So I declared them “manually” in the corresponding files. Then I’ve encountered another problem. In the documentation, the codes samples aren’t 100% correct. You have to do this add “@ORM\” instead of the simple “@“. Here my code that works:

    /**
     * @ORM\ManyToMany(targetEntity="Adresse", inversedBy="personnes")
     * @ORM\JoinTable(name="personne_adresse")
     **/
    private $adresses;
    /**
     * @ORM\ManyToMany(targetEntity="Partenaire", inversedBy="personnes")
     * @ORM\JoinTable(name="personne_partenaire")
     **/
    private $partenaires;
    /**
     * @ORM\ManyToMany(targetEntity="Telephone", inversedBy="personnes")
     * @ORM\JoinTable(name="personne_telephone")
     **/
    private $telephones;
    
    public function __construct() {
        $this->adresses = new \Doctrine\Common\Collections\ArrayCollection();
        $this->partenaires = new \Doctrine\Common\Collections\ArrayCollection();
        $this->telephones = new \Doctrine\Common\Collections\ArrayCollection();
    }
    

    Moreover, you have to delete corresponding ManyToMany Php files, because Symfony 2 (I guess) handle those “in-between” ManyToMany tables itself => no need to declare. In my sample, I had to delete “PersonneAdresse.php“, “PersonnePartenaire.php” and “PersonneTelephone.php“.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question here: is there any way to convert from a jagged array to
I've seen this here and there, but can't find any information regarding this thing.
I have been running around here and there on NoSQL big data storage technologies.
I apologize to move it from here as there was some confusion and thanks
I have this typical requirement here: There's a file in kernel /arch/arm/lib/csumpartial.S which has
Ok here's the the thing. I have a flash slideshow which runs from an
I have table A, below, where for each unique id, there are three codes
Here there, I have a custom UIView. This view acts as a activity indicator
I have a table with values: Key1 Key2 ColumnKey ============================ 1 idx1 here 2
Spring 3.1 + Tomcat I have a bit of a design question here: There

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.