Bug #29982

Wrong table structure for multiple ManyToOne relations

Added by Alexander Stehlik over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Should have
Category:
Persistence
Start date:
2011-09-18
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

I stumbled upon an issue when using two @ManyToOne properties in one model, that both point to the same related model (in my case it was a transaction that had an "account" and a "sourceOrTargetAccount" property. Both had the following annotation:

/**
 * @var \My\Namespace\MyPackage\Domain\Model\Account
 * @ManyToOne(cascade={"persist"})
 */

After calling doctrine:update there was only one column in the transaction table called mypackage_account that referenced values in the account table. Additionally I realised that the values of the sourceOrTargetAccount property were stored in this column. The value of the account property was not stored anywhere.

To fix this, I used the @JoinColumn annotation to specify the column:

@JoinColumn(name="source_or_target_account", referencedColumnName="flow3_persistence_identifier")

Maybe this behaviour is expected? If so this probably should be added to the docs.


Related issues

Is duplicate of TYPO3.Flow - Bug #30223: Column names for association properties are generated wrongResolvedKarsten Dambekalns2011-09-23

Actions
#1

Updated by Karsten Dambekalns over 9 years ago

  • Project changed from 478 to TYPO3.Flow
#2

Updated by Karsten Dambekalns over 9 years ago

  • Category set to Persistence
  • Status changed from New to Resolved
  • Assignee set to Karsten Dambekalns
  • Target version set to 1.0.0
  • % Done changed from 0 to 100

Resolved with #30223.

Also available in: Atom PDF