Bug #29982
Wrong table structure for multiple ManyToOne relations
Status: | Resolved | Start date: | 2011-09-18 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Karsten Dambekalns | % Done: | 100% |
|
Category: | Persistence | |||
Target version: | TYPO3 Flow Base Distribution - 1.0.0 | |||
PHP Version: | Complexity: | |||
Has patch: | Affected Flow version: |
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
History
#1 Updated by Karsten Dambekalns almost 4 years ago
- Project changed from Doctrine 2 to TYPO3.Flow
#2 Updated by Karsten Dambekalns almost 4 years ago
- Category set to Persistence
- Status changed from New to Resolved
- Assigned To set to Karsten Dambekalns
- Target version set to 1.0.0
- % Done changed from 0 to 100
Resolved with #30223.