[FLOW3-general] Integrity constraint violation
Georg Ortner
go at simplaweb.at
Tue Mar 2 09:40:59 CET 2010
Hi I have a persistence question:
I have a model Category. A Category should be able to save references to
it's child categories. Technically it does the same things like a post
saving references to related posts in the Blog tutorial:
/**
*
* @param \SplObjectStorage<\F3\MyPackage\Domain\Model\Category>
* @return void
*/
public function setSubCategories(\SplObjectStorage $subCategories) {
$this->subCategories = clone $subCategories;
}
As long as I do it this way it works just fine, but if I want a method
which just adds one child like this:
/**
* @param \F3\MyPackage\Domain\Model\Category $category
* @return void
*/
public function addSubCategory(\F3\MyPackage\Domain\Model\Category
$category) {
$this->subCategories->attach( clone $category );
}
I'm getting this exception when the persistence backend tries to persist
a Category:
#23000: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate
entry 'f40627ea-9452-4381-aa53-48f541051120' for key 1 (More information)
PDOException thrown in file
Packages/Framework/FLOW3/Classes/Persistence/Backend/GenericPdo/Backend.php
in line 179.
So what's the difference? And how in general can I save just a reference
to an Object of the same type as it self?
More information about the FLOW3-general
mailing list