protected function associateBeans(OODBBean $bean1, OODBBean $bean2, OODBBean $bean)
{
$type = $bean->getMeta('type');
$property1 = $bean1->getMeta('type') . '_id';
$property2 = $bean2->getMeta('type') . '_id';
if ($property1 == $property2) {
$property2 = $bean2->getMeta('type') . '2_id';
}
$this->oodb->store($bean1);
$this->oodb->store($bean2);
$bean->setMeta("cast.{$property1}", "id");
$bean->setMeta("cast.{$property2}", "id");
$bean->setMeta('sys.buildcommand.unique', array($property1, $property2));
$bean->{$property1} = $bean1->id;
$bean->{$property2} = $bean2->id;
$results = array();
try {
$id = $this->oodb->store($bean);
$results[] = $id;
} catch (SQLException $exception) {
if (!$this->writer->sqlStateIn($exception->getSQLState(), array(QueryWriter::C_SQLSTATE_INTEGRITY_CONSTRAINT_VIOLATION))) {
throw $exception;
}
}
return $results;
}