Hello! Do you have solved this? I have similar issue - JoinColumn name
ignored.
суббота, 1 декабря 2012 г., 16:48:37 UTC+1 пользователь Shu Chow написал:
>
> Hi, all. I posted this on StackOverflow and I thought I'd post it here to
> get better coverage. It's really making me scratch my head.
>
> I have a forum to thread One to Many bidirectional relationship.
>
> My forum mapping looks like this:
>
> #Forum.dcm.yml
>> Forum:
>> type: entity
>> table: Forum
>> id:
>> id:
>> type: integer
>> generator:
>> strategy: AUTO
>> fields:
>> name:
>> type: text
>> description:
>> type: text
>> oneToMany:
>> threads:
>> targetEntity: Thread
>> mappedBy: forum
>
>
> And the thread mapping:
>
> #Thread.dcm.yml
>
> Thread:
>> type: entity
>> table: Thread
>> id:
>> id:
>> type: integer
>> generator:
>> strategy: AUTO
>> fields:
>> name:
>> type: text
>> createdOn:
>> type: text
>> manyToOne:
>> forum:
>> fetch: EAGER
>> targetEntity: Forum
>> inversedBy: threads
>> joinColumm:
>> name: forumId
>> referencedColumnName: id
>> creator:
>> targetEntity: User
>> joinColumn:
>> name: creatorId
>> referencedColumnName: id
>> oneToMany:
>> comments:
>> targetEntity: Comment
>> mappedBy: thread
>
>
> The problem is when I try to get the children of the forum, the threads,
> Doctrine2 is ignoring the name specified in joinColumn:
>
> $result = $this->_entityManager->find('Forum', $id);
>> $threads = $result->getThreads();
>
>
> I'm getting this error
>
> SELECT t0.id AS id1, t0.name AS name2, t0.createdOn AS createdOn3,
>> t0.forum_id AS forum_id4, t5.id AS id6, t5.name AS name7, t5.description
>> AS description8, t0.creatorId AS creatorId9 FROM Thread t0 LEFT JOIN Forum
>> t5 ON t0.forum_id = t5.id WHERE t0.forum_id = ? array(1) { [0]=> int(2)
>> } array(1) { [0]=> NULL }
>>
>> Fatal error: Uncaught exception 'PDOException' with message
>> 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.forum_id' in
>> 'field list''
>
>
> Note specifically *t0.forum_id* in the join and where clauses. It's like
> Doctrine is ignoring the name field in my joinColumn declaration and
> defaulting to *_id. Any idea of what's causing this and what's the fix?
>
> In my thread table, the column that holds that foreign key is named
> "forumId":
>
> +-----------+--------------+------+-----+---------+----------------+
>> | Field | Type | Null | Key | Default | Extra |
>> +-----------+--------------+------+-----+---------+----------------+
>> | id | int(11) | NO | PRI | NULL | auto_increment |
>> | name | varchar(255) | NO | | NULL | |
>> | createdOn | date | NO | | NULL | |
>> | creatorId | int(11) | NO | | NULL | |
>> | forumId | int(11) | NO | | NULL | |
>> +-----------+--------------+------+-----+---------+----------------+
>
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.