'Doctrine composite primary key as part of the primary key of another entity

I have specific situation where composite primary key of one entity is part of the primary key of another entity. This is case of specialization, but it doesn't matter now.

I use Doctrine to generate entities from database, but Doctrine doesn't support composite foreign key as primary key:

It is not possible to map entity 'XXXXX' with a composite primary key as part of the primary key of another entity 'YYYYYY#id_xxxxx'

Does anyone know solution for this situation? It can be Doctrine solution or editing model and database structure.

UPDATE 1

CREATE TABLE `amandman` (
  `iddokumenta` int(11) NOT NULL,
  `datumdostavljanjaskupstini` date NOT NULL,
  `tekst` text,
  `datumizmene` date DEFAULT NULL,
  `izmenjenitekst` text,
  `iddokumentapredlogazakona` int(11) DEFAULT NULL,
  `datumdostavljanjaskupstinipredlogazakona` date DEFAULT NULL,
  PRIMARY KEY (`iddokumenta`,`datumdostavljanjaskupstini`),
  KEY `iddokumentapredlogazakona_idx`           (`iddokumentapredlogazakona`,`datumdostavljanjaskupstinipredlogazakona`),
  CONSTRAINT `iddokumenta45` FOREIGN KEY (`iddokumenta`, `datumdostavljanjaskupstini`)     REFERENCES `dokument` (`iddokument`, `datumdostavljanjaskupstini`) ON DELETE NO ACTION ON     UPDATE CASCADE,
 CONSTRAINT `iddokumentapredlogazakona` FOREIGN KEY (`iddokumentapredlogazakona`, `datumdostavljanjaskupstinipredlogazakona`) REFERENCES `predlogzakona` (`iddokumenta`, `datumdostavljanjaskupstini`) ON DELETE NO ACTION ON UPDATE CASCADE) 
ENGINE=InnoDB DEFAULT CHARSET=utf8;

This is one of entities from database that can't be generated by Doctrine.



Solution 1:[1]

The foreign key ever is a primary key in other table and why it's not a good practice?. The solution is remove the foreign key relation from the database, after add it manually. Well if you are using cascade update or similar it's necesary or you can control the update/delete with code and not with relation of tables

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JOSE CALAMBROGIO