composite-primary-key

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

最后都变了- 提交于 2021-02-05 05:52:08
问题 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

MySQL cascade update failed when foreign key column referenced in composite primary key

耗尽温柔 提交于 2021-01-28 11:44:44
问题 Unlike the similar other questions, I get error #1452 when updating the parent row. Why does it happen? Thank you in advance. Here are the relevant tables: CREATE TABLE IF NOT EXISTS `user` ( `username` VARCHAR(100) NOT NULL, `password` VARCHAR(200) NOT NULL, `name` VARCHAR(100), `surname` VARCHAR(100), `icon` BLOB, PRIMARY KEY (username) ); CREATE TABLE IF NOT EXISTS `document` ( `owner` VARCHAR(100) NOT NULL, `name` VARCHAR(100) NOT NULL, `sharing_link` VARCHAR(200) UNIQUE NOT NULL, PRIMARY

MySQL cascade update failed when foreign key column referenced in composite primary key

依然范特西╮ 提交于 2021-01-28 11:34:26
问题 Unlike the similar other questions, I get error #1452 when updating the parent row. Why does it happen? Thank you in advance. Here are the relevant tables: CREATE TABLE IF NOT EXISTS `user` ( `username` VARCHAR(100) NOT NULL, `password` VARCHAR(200) NOT NULL, `name` VARCHAR(100), `surname` VARCHAR(100), `icon` BLOB, PRIMARY KEY (username) ); CREATE TABLE IF NOT EXISTS `document` ( `owner` VARCHAR(100) NOT NULL, `name` VARCHAR(100) NOT NULL, `sharing_link` VARCHAR(200) UNIQUE NOT NULL, PRIMARY

Cascading a Child entity persist operation to its Parent entity

南笙酒味 提交于 2021-01-28 00:30:23
问题 I have a OneToMany association with two entities that I have set up using Hibernate annotations. The Child entity of this association has a composite primary key that consists of the foreign key parent column and another identifier childName . This seems to cause a "Referential integrity constraint violation" when I attempt to cascade a commit to the parent by saving the child entity. I have created a simple working example of the issue that abstracts away from the actual scenario that I am

How to delete multiple rows with 2 columns as composite primary key in MySQL?

纵饮孤独 提交于 2021-01-16 12:32:48
问题 My innodb table has the following structure: 4 columns (CountryID, Year, %Change, Source) , with the 2 columns (CountryID, Year) as the primary key. How do I delete multiple rows other than using a for-loop to delete each row? I'm looking for something similar to DELETE FROM CPI WHERE CountryID AND Year IN (('AD', 2010), ('AF', 2009), ('AG', 1992)) 回答1: The answer in Oracle is: delete from cpi where (countryid, year) in (('AD', 2010), ('AF', 2009), ('AG', 1992)) It's fairly standard SQL

How to delete multiple rows with 2 columns as composite primary key in MySQL?

血红的双手。 提交于 2021-01-16 12:28:16
问题 My innodb table has the following structure: 4 columns (CountryID, Year, %Change, Source) , with the 2 columns (CountryID, Year) as the primary key. How do I delete multiple rows other than using a for-loop to delete each row? I'm looking for something similar to DELETE FROM CPI WHERE CountryID AND Year IN (('AD', 2010), ('AF', 2009), ('AG', 1992)) 回答1: The answer in Oracle is: delete from cpi where (countryid, year) in (('AD', 2010), ('AF', 2009), ('AG', 1992)) It's fairly standard SQL