[Flow] Best practice for Persist Value Object

Rocky rockysynergy at gmail.com
Fri Oct 17 08:01:55 CEST 2014


Hi Christian,

Thanks! Now the value objects could be persisted. 

But the problem is when remove the model, I will get SQL error saying "SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (...". The reason is Doctrine will generate 2 tables. Below are the SQL:
 CREATE TABLE `hwwcn_sponsor_domain_model_abstractapplication_expenses_join` (
  `sponsor_abstractapplication` varchar(40) NOT NULL,
  `hwwcn_model_expense` varchar(40) NOT NULL,
  PRIMARY KEY (`sponsor_abstractapplication`,`hwwcn_model_expense`),
  KEY `IDX_26B5C670561DC0D6` (`sponsor_abstractapplication`),
  KEY `IDX_26B5C67058C3DB9F` (`hwwcn_model_expense`),
  CONSTRAINT `FK_26B5C67058C3DB9F` FOREIGN KEY (`hwwcn_model_expense`) REFERENCES `hwwcn_sponsor_domain_model_expense` (`persistence_object_identifier`),  
  CONSTRAINT `FK_26B5C670561DC0D6` FOREIGN KEY (`sponsor_abstractapplication`) REFERENCES `hwwcn_sponsor_domain_model_abstractapplication` (`persistence_object_identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `hwwcn_sponsor_domain_model_expense` (
  `persistence_object_identifier` varchar(40) NOT NULL,
  `item` varchar(255) NOT NULL,
  `amount` double NOT NULL,
  PRIMARY KEY (`persistence_object_identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 

If I delete the foreign key part when create the join table, I could delete the expense but that will make other records in the join table refer to deleted expense which is not longer exist. Any suggestion please?


More information about the Flow mailing list