[MODM-75] mappedSuperclass and embedded document not working with yaml mapping Created: 10/Sep/10  Updated: 24/Nov/10  Resolved: 24/Nov/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: None
Fix Version/s: 1.0.0BETA2

Type: Bug Priority: Major
Reporter: julien rollin Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

all documents inherits from an abstract class Cgd\DomainObject\DomainObjectAbstract

The document App\Entity\Contact\Contact has many App\Entity\Contact\Program

abstract class Cgd\DomainObject\DomainObjectAbstract

mappedSuperclass
#Cgd.DomainObject.DomainObjectAbstract.dcm.yml
Cgd\DomainObject\DomainObjectAbstract:
  type: mappedSuperclass
  fields:
    id:
      fieldName: id
      id: true
    createdAt:
      fieldName: createdAt
      type: date
    updatedAt:
      fieldName: updatedAt
      type: date
  lifecycleCallbacks:
    prePersist: [onPreInsert]
    preUpdate: [onPreUpdate]

Here the inherited class

class App\Entity\Contact\Contact extends Cgd\DomainObject\DomainObjectAbstract

InheritedClass
#App.Entity.Contact.Contact.dcm.yml
App\Entity\Contact\Contact:
  collection: contacts
  type: document
  fields:
    email:
      fieldName: email
      type: string
    status:
      fieldName: status
      type: int
  embedMany:
    programs:
      targetDocument: App\Entity\Contact\Program
      cascade: all

The embedded

class App\Entity\Contact\Program extends Cgd\DomainObject\DomainObjectAbstract

embeddedDocument
#App.Entity.Contact.Program.dcm.yml
App\Entity\Contact\Program:
  type: embeddedDocument
  fields:
    name:
      fieldName: name
      type: string

No field from abstract class are populated in embedded document



 Comments   
Comment by julien rollin [ 10/Sep/10 ]

if i call

$dm->persist($contact);
$dm->flush();

properties createdAt and updatedAt are saved to contact document only

if i call

$dm->persist($program);
$dm->persist($contact);
$dm->flush();

properties createdAt and updatedAt are saved to contact and embedded documents.

So is it the "cascade: all" property the problem ?

Comment by Jonathan H. Wage [ 10/Sep/10 ]

Are you using the absolute latest version from git? we made some changes recently to cascading and embedded documents. It is not necessary anymore to specify any cascading options as it does not make sense for embedded documents. it should and does cascade by default now for embedded documents.

Comment by julien rollin [ 10/Sep/10 ]

yes i use the remote origin/master (i just did an update to de2e671201ef5a97e2a970f35cc94b5ad3590bb5)

but actually, since your my comments and after yours, i got this beautiful fatal error (unknown before )

Fatal error: Class Doctrine\ODM\MongoDB\Query\Lexer contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Doctrine\Common\Lexer::_getType) in D:\web\php\doctrine2-mongodb\lib\Doctrine\ODM\MongoDB\Query\Lexer.php on line 33

edit : rechecking all dependencies (doctrine/common, etc )

edit 2 : last checkout resolved cascade persist

Generated at Mon Sep 01 07:38:27 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.