Jump to content

Doctrine 2 Bidirectional One to Many Relationship loading extremely slow


blacktie524

Recommended Posts

I am just starting out with Doctrine 2 and trying to test out a bidirectional One to Many relationship.  In this case, I have a user, which can have many comments.  I have checked the Doctrine 2 documentation and it seems that I am doing it right, but it takes a really looong time to execute my script (with just a few rows in each tables), and I'm hoping someone can help point me in the right direction.  Here is the php:

 

    /**

    * @Entity

    * @Table(name="users")

    */

   

    class User

    {

 

/**

* @Id @GeneratedValue

* @Column(type="bigint")

* @var integer

*/

private $id;

 

/**

* @Column(type="string", length="250")

* @var string

*/

protected $name;

 

/**

* @OneToMany(targetEntity="Comment", mappedBy="user")

*/

private $comments;

 

    }

 

    /**

    * @Entity

    * @Table(name="comments")

    */

    class Comment

    {

/**

* @Id @GeneratedValue

* @Column(type="bigint")

* @var integer

*/

private $id;

 

/**

* @Column(type="text")

* @var string

*/

private $text;

 

/**

* @ManyToOne(targetEntity="User", inversedBy="comments")

* @JoinColumn(name="user_id", "referencedColumnName="id")

*/

private $user;

    }

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.