_schemaTool->createSchema(array( $this->_em->getClassMetadata(DDC2579Entity::CLASSNAME), $this->_em->getClassMetadata(DDC2579EntityAssoc::CLASSNAME), $this->_em->getClassMetadata(DDC2579AssocAssoc::CLASSNAME), )); } public function testIssue() { $id = new DDC2579Id("foo"); $assoc = new DDC2579AssocAssoc($id); $assocAssoc = new DDC2579EntityAssoc($assoc); $entity = new DDC2579Entity($assocAssoc); $repository = $this->_em->getRepository(DDC2579Entity::CLASSNAME); $this->_em->persist($assoc); $this->_em->persist($assocAssoc); $this->_em->persist($entity); $this->_em->flush(); $entity->value++; $this->_em->persist($entity); $this->_em->flush(); $this->_em->clear(); $id = $entity->id; $value = $entity->value; $criteria = array('assoc' => $assoc, 'id' => $id); $entity = $repository->findOneBy($criteria); $this->assertInstanceOf(DDC2579Entity::CLASSNAME, $entity); $this->assertEquals($value, $entity->value); $this->_em->remove($entity); $this->_em->flush(); $this->_em->clear(); $this->assertNull($repository->findOneBy($criteria)); $this->assertCount(0, $repository->findAll()); } } /** * @Entity */ class DDC2579Entity { const CLASSNAME = __CLASS__; /** * @Id * @Column(type="ddc2579") */ public $id; /** * @Id * @ManyToOne(targetEntity="DDC2579EntityAssoc") * @JoinColumn(name="relation_id", referencedColumnName="association_id") */ public $assoc; /** * @Column(type="integer") */ public $value; public function __construct(DDC2579EntityAssoc $assoc, $value = 0) { $this->id = $assoc->assocAssoc->associationId; $this->assoc = $assoc; $this->value = $value; } } /** * @Entity */ class DDC2579EntityAssoc { const CLASSNAME = __CLASS__; /** * @Id * @ManyToOne(targetEntity="DDC2579AssocAssoc") * @JoinColumn(name="association_id", referencedColumnName="associationId") */ public $assocAssoc; public function __construct(DDC2579AssocAssoc $assocAssoc) { $this->assocAssoc = $assocAssoc; } } /** * @Entity */ class DDC2579AssocAssoc { const CLASSNAME = __CLASS__; /** * @Id * @Column(type="ddc2579") */ public $associationId; public function __construct(DDC2579Id $id) { $this->associationId = $id; } } class DDC2579Type extends StringType { const NAME = 'ddc2579'; const CLASSNAME = __CLASS__; /** * {@inheritdoc} */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { return (string)$value; } public function convertToPhpValue($value, AbstractPlatform $platform) { return new DDC2579Id($value); } /** * {@inheritdoc} */ public function getName() { return self::NAME; } } class DDC2579Id { const CLASSNAME = __CLASS__; private $val; public function __construct($val) { $this->val = $val; } public function __toString() { return $this->val; } }